[prog] [C/C++] what to put in header files.
Kathryn Hogg
kjh at flyballdogs.com
Fri Sep 20 08:31:01 EST 2002
> On the other hand, if there is a class named Foo, and another class
> (Bar) has a member attribute of type pointer to Foo, then the compiler
> does _not_ need to see the definition of class Bar to compile Foo.
> Consequently, you do
> not need to include the header, you can simply say within the file
> defining Foo:
>
> class Bar;
>
> and this will satisfy the compiler.
Unfortunately, that style can cause problems on some systems with template
instantiation because the template database may record "class Bar" as
being declared in Foo.h.
And of course you must include the full definition of class Bar if you
actually dereference a "Bar *".
--
Kathryn
More information about the Programming
mailing list