Click here to Skip to main content
11,706,007 members (46,238 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: MFC VC++
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
Sergey Alexandrovich Kryukov at 4-Mar-13 2:08am
The problem is not related to variable (member) initialization. You are just using unresolved symbol.
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
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
0 OriginalGriff 196
1 Sergey Alexandrovich Kryukov 151
2 ppolymorphe 61
3 Inimicos 60
4 ProgramFOX 50
0 OriginalGriff 9,050
1 Sergey Alexandrovich Kryukov 8,417
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,636

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 4 Mar 2013
Copyright © CodeProject, 1999-2015
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