|
-
July 7th, 2011, 11:43 PM
#5
Re: error LNK2001: unresolved external symbol
I was declared and define in the same file(as per C programing concept). In C++, declartion goes to header file and definitions should be in CPP file.
Actually, C and C++ share the same concept. As per design, C++ was made a successor to C.
Header files contain declarations with external linkage (functions are automatically given the one), while compile units (.c or .cpp) contain definitions. Without external declaration a variable is limited to unit scope, compiler generates allocation code for the variable, and its references appear resolved immediately in the unit scope. External declaration instructs to resolve references in the other units (link them to variable real location) on a later stage by linker. That's why linker is called linker.
Last edited by Igor Vartanov; July 8th, 2011 at 12:04 AM.
Best regards,
Igor
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|