> class A
> {
> .....
> private:
> class B;
> };
>
> Assume A is defined in A.h and B is defined in B.h Here the
> composition of A depends on the type B.
>
> Say code in file "one.cpp" wants to create objects of type A.
> 1) Either in one.cpp we first include B.h followed by A.h OR
> 2) We include B.h in the file A.h.
>
> Which approach is better ? I feel per module there must be a common
> header file. Also, is it absolutely evil/bad to include header files
> within header files?
Actually, I would #include "B.h" in A.h, so that anywhere you include A.h,
it just works without you needing to worry about what headers should be
included before it.
You should just use #include guards, or #pragma once to make sure the same
header is not included multiple times in a translation unit.
-------------
Ehsan Akhgari
Farda Technology (http://www.farda-tech.com/)
List Owner: [email protected]
[ Email: [EMAIL PROTECTED] ]
[ WWW: http://www.beginthread.com/Ehsan ]
Under conditions of peace the warlike man attacks himself.
-Beyond Good And Evil, F. W. Nietzsche
_______________________________________________
msvc mailing list
[email protected]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for
subscription changes, and list archive.