header files

From: mike ttoouli (mttoouli_at_yahoo.com)
Date: 04/04/04


Date: 4 Apr 2004 13:49:22 -0700

Hi

I'm a little confused about the reason for using both header and cpp
files in a project. As all code can be written in the header file
itself, why use cpp files at all?

I can see there being a redeclaration issue if a header file is
included multiple times in a large project, but can't this be
by-passed with #ifndef /#define /#endif ?

I know this is probably very bad form - can anyone tell me the reasons
for the .h / .cpp system?

thanks

mike



Relevant Pages

  • Re: header file problem
    ... i did at first time the same procedure you descirbed ... and then i try to learn using header file and definiton file ... resolving excercise it my lovely book - thniking in cpp. ... now im sure that was a compiler bug, because i create my car.h and car.cpp ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Header file + implementation file with template
    ... > I have a problem on using header file and template. ... > If I put the interface/declaration of a class template in a header ... often use .tcc or even .cpp. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Proper Including Style
    ... >>duplication is bad (if you have to add a header file, ... > if your implementation changes and requires a new header ... > instead of just your .cpp file as it should. ... it should be included *only* in the .cpp source file. ...
    (comp.lang.cpp)
  • Re: What is the purpose of a ChildView?
    ... you know that a .h file is the header file! ... it would be insane to *not* have a .cpp and .h file to represent a class ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Best Practices: #include
    ... I was wondering what those in this group consider 'best practices' when ... including a header file: in the .cpp or .h. ... Balboos ...
    (microsoft.public.vc.mfc)