Click here to Skip to main content
15,921,463 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dialog Box Variable Pin
bkelly134-Jul-08 4:19
bkelly134-Jul-08 4:19 
QuestionA class method definition in a header file... just one problem. Pin
Tomasz Morawski1-Jul-08 11:33
Tomasz Morawski1-Jul-08 11:33 
AnswerRe: A class method definition in a header file... just one problem. Pin
Bram van Kampen1-Jul-08 12:01
Bram van Kampen1-Jul-08 12:01 
This will happen if the header file is included in more than one cpp file. The compiler compiles cpp files, and indoing so, complles any code found in the included header. in other words, if both files 'Main.cpp' and 'another.cpp' include the header, A::foo() wil be included in both 'Main.obj' and 'another.obj'. Sofar so good no problems yet. Next we get the linker. it tries to stitch all obj files together into one executable. When it tries to resolve a call to A::foo(), it find that it has two options, it has to choose one. This is what the linker cannot do, and hence it gives the linker error and fails. If you want to keep the function definition in the header file, (although I don't know why you should want to do this) prefix it with the '__inline' directive.

Hope this explains the issue,

Regards, Smile | :)

Bram van Kampen

GeneralRe: A class method definition in a header file... just one problem. Pin
Stephen Hewitt1-Jul-08 13:58
Stephen Hewitt1-Jul-08 13:58 
GeneralRe: A class method definition in a header file... just one problem. Pin
Bram van Kampen1-Jul-08 14:55
Bram van Kampen1-Jul-08 14:55 
GeneralRe: A class method definition in a header file... just one problem. Pin
Tomasz Morawski1-Jul-08 18:23
Tomasz Morawski1-Jul-08 18:23 
GeneralRe: A class method definition in a header file... just one problem. Pin
Tomasz Morawski1-Jul-08 18:41
Tomasz Morawski1-Jul-08 18:41 
GeneralRe: A class method definition in a header file... just one problem. Pin
Bram van Kampen1-Jul-08 21:48
Bram van Kampen1-Jul-08 21:48 
GeneralRe: A class method definition in a header file... just one problem. Pin
Tomasz Morawski2-Jul-08 0:53
Tomasz Morawski2-Jul-08 0:53 
GeneralRe: A class method definition in a header file... just one problem. Pin
Tomasz Morawski2-Jul-08 0:54
Tomasz Morawski2-Jul-08 0:54 
GeneralRe: A class method definition in a header file... just one problem. Pin
Bram van Kampen2-Jul-08 11:24
Bram van Kampen2-Jul-08 11:24 
GeneralRe: A class method definition in a header file... just one problem. Pin
Tomasz Morawski3-Jul-08 8:13
Tomasz Morawski3-Jul-08 8:13 
GeneralRe: A class method definition in a header file... just one problem. Pin
Bram van Kampen3-Jul-08 8:28
Bram van Kampen3-Jul-08 8:28 
GeneralRe: A class method definition in a header file... just one problem. [modified] Pin
Tomasz Morawski3-Jul-08 8:41
Tomasz Morawski3-Jul-08 8:41 
GeneralRe: A class method definition in a header file... just one problem. Pin
Bram van Kampen3-Jul-08 10:42
Bram van Kampen3-Jul-08 10:42 
GeneralRe: A class method definition in a header file... just one problem. Pin
Tomasz Morawski3-Jul-08 21:06
Tomasz Morawski3-Jul-08 21:06 
GeneralRe: A class method definition in a header file... just one problem. Pin
Bram van Kampen5-Jul-08 15:13
Bram van Kampen5-Jul-08 15:13 
AnswerRe: A class method definition in a header file... just one problem. Pin
Bram van Kampen1-Jul-08 21:55
Bram van Kampen1-Jul-08 21:55 
AnswerRe: A class method definition in a header file... just one problem. Pin
Stephen Hewitt1-Jul-08 14:11
Stephen Hewitt1-Jul-08 14:11 
QuestionHow to add a tag <tag val="N"> to an xml file Pin
SWDevil1-Jul-08 6:28
SWDevil1-Jul-08 6:28 
AnswerRe: How to add a tag <tag val="N"> to an xml file</tag> Pin
led mike1-Jul-08 7:47
led mike1-Jul-08 7:47 
GeneralRe: How to add a tag to an xml file Pin
SWDevil1-Jul-08 8:58
SWDevil1-Jul-08 8:58 
GeneralRe: How to add a tag to an xml file Pin
led mike1-Jul-08 11:05
led mike1-Jul-08 11:05 
QuestionOnly max & close button on CMDIChild window Pin
jigna gala1-Jul-08 2:55
jigna gala1-Jul-08 2:55 
AnswerRe: Only max & close button on CMDIChild window Pin
David Crow1-Jul-08 4:03
David Crow1-Jul-08 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.