Re: code in header file?

From: Pedro Graca (hexkid+usenet_at_gmail.com)
Date: 11/09/04


Date: 9 Nov 2004 16:17:04 GMT

Marko Zagar wrote:
> Pedro Graca wrote:
>
>> My questions are:
>>
>> is it ok to add code in the header file?
>> is it better to change that definition to a declaration and write the
>> definition in the corresponding .cpp file (maybe with the inline keyword)?
>> What are the [dis]advantages of having code in the header file?
>
> Aside from longer compile and link times (if you include that header in
> other cpp files, the same code will be compiled again), I see no problem.
>
> If you change the location of code there should be no problems, except
> maybe any automization thinggies by M$ that might not be able to find
> it, but I think that's unlikely.

Thank you Marko.

I feel better having the code in the .cpp file (probably inline'd).
I'll try to remember to make the relevant changes and not accept
Microsoft defaults.

-- 
USENET would be a better place if everybody read:    | to  mail  me:  simply |
http://www.catb.org/~esr/faqs/smart-questions.html   | "reply" to this post, |
http://www.netmeister.org/news/learn2quote2.html     | *NO* MIME, plain text |
http://www.expita.com/nomime.html                    | and *NO* attachments. |


Relevant Pages

  • Re: forms implementation should be in .cpp not .hpp file
    ... Why VS2008 doesn't create .cpp files when creating new form using ... file not in the header file. ... deliver service pack like compatibility for WindowsForms. ... Stop jumping saying "developers, developers, developers" and ...
    (microsoft.public.vc.ide_general)
  • Preprocessor, nested files etc.
    ... I expected one big file but instead got one preprocessor file for each ... of the cpp files in the project. ... when I #define macros and put them at the beginning of the header file ... then those macro definitions don't seem to stick. ...
    (comp.lang.cpp)
  • Re: header files
    ... >hi jeffc, sorry I wasn't being very clear. ... >It was never my intention to create one big file - lots separate files, ... >then this would ensure that the header file is added only the first time it ... If you cannot see the point of .cpp files I suspect you do not ...
    (alt.comp.lang.learn.c-cpp)
  • Re: header files
    ... It was never my intention to create one big file - lots separate files, ... This would lead to the problem of including the same header file in more ... then this would ensure that the header file is added only the first time it ... and I couldn't really see the point of .cpp files at ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Internal Complier Error in VC++ 1.52
    ... You may have hit some brick wall in the compiler. ... I am working on an existing code base where the no of lines is around 100,000, spread across different header and cpp files. ... when i was trying to add a new function declaration for an existing class in a header file and function implementation in the .cpp file i am getting an error as given below ... CL returned error code 2. ...
    (microsoft.public.vc.mfc)