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 OriginalGriff 428
1 Maciej Los 249
2 BillWoodruff 199
3 /\jmot 180
4 Suraj Sahoo | Coding Passion 150
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.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