Click here to Skip to main content
15,895,011 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Serialization from a CPropertypage class behaves differently Pin
«_Superman_»7-Nov-09 18:41
professional«_Superman_»7-Nov-09 18:41 
GeneralRe: Serialization from a CPropertypage class behaves differently [modified] Pin
al25008-Nov-09 8:04
al25008-Nov-09 8:04 
QuestionBeginner question using headers Pin
Jacob Dixon7-Nov-09 10:49
Jacob Dixon7-Nov-09 10:49 
AnswerRe: Beginner question using headers Pin
Jacob Dixon7-Nov-09 10:53
Jacob Dixon7-Nov-09 10:53 
GeneralRe: Beginner question using headers Pin
«_Superman_»7-Nov-09 10:57
professional«_Superman_»7-Nov-09 10:57 
AnswerRe: Beginner question using headers Pin
«_Superman_»7-Nov-09 10:56
professional«_Superman_»7-Nov-09 10:56 
GeneralRe: Beginner question using headers Pin
Jacob Dixon7-Nov-09 11:30
Jacob Dixon7-Nov-09 11:30 
GeneralRe: Beginner question using headers Pin
Chris Losinger7-Nov-09 14:37
professionalChris Losinger7-Nov-09 14:37 
in general, you should avoid putting code in a .H file.

put this in the .C/.CPP:

int add(int x, int y)
{
return x + y;
}


and put this in the .H:

extern int add(int x, int y);


that extern says "there is a function which looks like this, but is implemented somewhere else". that will satisfy the compiler. the linker will take care of the rest.

the reason you don't want to put code in a .H file is that someday you might end up #including that .H into multiple .CPP files, and when you do that, you're going to get linker errors complaining about a multiply-defined symbol called "add".

think of what #include does: the C/C++ preprocessor literally inserts the text of the .H file into the place where you did the #include, before starting the compilation. so if you #include that .H file into multiple .CPPs, you will get multiple copies of the .H file contents. and if the .H file has a function, you'll get multiple copies of that function.

about the only time you'll do implementation in a .H file is if the function is a class member function.


GeneralRe: Beginner question using headers Pin
Jacob Dixon7-Nov-09 14:41
Jacob Dixon7-Nov-09 14:41 
GeneralRe: Beginner question using headers Pin
Tim Craig7-Nov-09 21:07
Tim Craig7-Nov-09 21:07 
GeneralRe: Beginner question using headers [modified] Pin
LunaticFringe8-Nov-09 8:49
LunaticFringe8-Nov-09 8:49 
GeneralRe: Beginner question using headers Pin
Chris Losinger8-Nov-09 10:13
professionalChris Losinger8-Nov-09 10:13 
GeneralRe: Beginner question using headers Pin
LunaticFringe8-Nov-09 10:26
LunaticFringe8-Nov-09 10:26 
QuestionGet IExplorerBrowser from a Windows Explorer (Vista) Pin
Ivo Beltchev7-Nov-09 7:35
Ivo Beltchev7-Nov-09 7:35 
QuestionImage in word document Pin
arpanmukherjee17-Nov-09 4:28
arpanmukherjee17-Nov-09 4:28 
AnswerRe: Image in word document Pin
Maximilien7-Nov-09 5:24
Maximilien7-Nov-09 5:24 
GeneralRe: Image in word document Pin
arpanmukherjee17-Nov-09 23:35
arpanmukherjee17-Nov-09 23:35 
GeneralRe: Image in word document Pin
Rajesh R Subramanian8-Nov-09 19:57
professionalRajesh R Subramanian8-Nov-09 19:57 
QuestionHow to join two programes? Pin
Waldemar Ork7-Nov-09 3:33
Waldemar Ork7-Nov-09 3:33 
AnswerRe: How to join two programes? Pin
LunaticFringe7-Nov-09 7:19
LunaticFringe7-Nov-09 7:19 
GeneralRe: How to join two programes? Pin
Waldemar Ork7-Nov-09 8:00
Waldemar Ork7-Nov-09 8:00 
GeneralRe: How to join two programes? Pin
LunaticFringe7-Nov-09 8:42
LunaticFringe7-Nov-09 8:42 
GeneralRe: How to join two programes? Pin
Waldemar Ork8-Nov-09 0:20
Waldemar Ork8-Nov-09 0:20 
GeneralRe: How to join two programes? Pin
Richard Andrew x648-Nov-09 6:55
professionalRichard Andrew x648-Nov-09 6:55 
GeneralRe: How to join two programes? Pin
LunaticFringe8-Nov-09 8:05
LunaticFringe8-Nov-09 8:05 

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.