Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC VC++
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
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 20:21pm
Comments
Sergey Alexandrovich Kryukov at 4-Mar-13 2:08am
   
The problem is not related to variable (member) initialization. You are just using unresolved symbol.
—SA
Sameer_awana at 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
good
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;    
  Permalink  

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

  Print Answers RSS
0 BillWoodruff 260
1 Mathew Soji 244
2 Afzaal Ahmad Zeeshan 232
3 OriginalGriff 231
4 Maciej Los 230
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,045


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 4 Mar 2013
Copyright © CodeProject, 1999-2014
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