Click here to Skip to main content
13,046,773 members (40,607 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am going to design one mfc application in which I make one common cpp class contains header file with that,I include that header file in all subfiles in my project & declare variables in that header file with public access specifier,but when I am going to define that variable presided by extern keyword in sub files,but it not accessed & give error as
error LNK2001: unresolved external symbol "void * i_acc_no" (?i_acc_no@@3PAXA)  Add_account.obj
so how to solve that problem??
Posted 3-Mar-13 19:21pm
The problem is not related to variable (member) initialization. You are just using unresolved symbol.
Sameer_awana 4-Mar-13 2:20am
ok,so how to initialise variable in constructor in mfc? and it should accessible in other subfiles also!

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to declare and initialise them in one code file. Something like:
// main.cpp
extern className::variableName = 0;    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 4 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100