J
Jonathan Mcdougall
Christian said:Hi,
I've a problem with including header files.
class A requires header file of class B
class B requires header file of class C
class C requires header file of class A
As can be seen the includes are cyclic. Since
I'm using
#ifndef _FILENAME
#define _FILENAME
...
#endif
in the header files, the include of header file
of class A in class C is not performed.
Is there any way to solve that problem or should I revise
the class design?
Forward declarations usually solve this problem. By declaring, for
example, class B in the header of class A, you don't need to include
the header.
You could perhaps split the headers in different parts. For example, if
the header for class B contains the class definition and something
else, you could put the something else elsewhere. Perhaps then class C
would be able to include that something else from elsewhere.
But if you really need to include them that way, well, C++ can't do
nothing for you.
Jonathan