RE: [Dev-C++] Organisation of header files
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <iv...@em...> - 2003-07-09 01:13:55
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Michael Stather
> Sent: Tuesday, July 08, 2003 11:59 PM
> To: dev...@li...
> Subject: [Dev-C++] Organisation of header files
>=20
>=20
> Hi,
>=20
> I divide my classes in a .cpp-file and a
> header-file (as suggested).
> Now I=B4ve heard of 3 possibilities to organise the
> dependencies:
>=20
> 1. Include only one header file in the
> implementation file, and in this header file,
> beside the class declaration include all required
> headers
>=20
> 2. Include the header which are important for the
> public interface of the class in the .cpp-file,
> and those who are only important for the methods
> "inside" the class in its header file (sounds the
> most logical)
>=20
> 3. Don=B4t include any header-file in the
> class-header, but include them all in the
> .cpp-file (before the actual class-header)
>=20
> Which solution is the best? (Or perhaps a
> completely different solution)
>=20
> Thanks for your help!!
I have got a headache so here you go. For non-template classes:
1) You can place the definition of the class in all the files you use =
the
class, that is you can place it in a header file and include that header
file to all the .cpp files you use the class.
This means that for every change in the definition of the class, you =
will
have to recompile all the source code files which have the definition =
(the
header).
2) Place the definition of the class in the header file except of the =
member
functions (usually the large ones) that should be defined out of the
definition of the class:
Example:
---- myheader.h
class A
{
int s;
public:
A(int r):s(r) {}
void great_things() const;
};
--- myheader.cpp
#include "myheader.h"
void A::great_things() const
{
// ...
}
For every change in the .cpp file only, no other source code files is =
needed
to be recompiled.
Ioannis Vranos
=20
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
|