Click here to Skip to main content
15,895,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi!
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
VB
error LNK2001: unresolved external symbol "void * i_acc_no" (?i_acc_no@@3PAXA)  Add_account.obj
so how to solve that problem??
Posted
Comments
Sergey Alexandrovich Kryukov 4-Mar-13 2:08am    
The problem is not related to variable (member) initialization. You are just using unresolved symbol.
—SA
Venkat Raghvan 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

You need to declare and initialise them in one code file. Something like:
C++
// main.cpp

extern className::variableName = 0;    
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900