#include h files

May 22, 2013 at 3:55pm
hi, guys i have a problem. I am doing my homework and came a cross a problem.
I have two include files which call each other, and the program doesn't work. is there any way to fix this? i thought that #ifndef will help me but it doesn't.

thanks!
May 22, 2013 at 3:58pm
It's probably a circular dependency between the classes in the headers.

Try including one of the headers in the the source file of the other, rather than the header.
May 22, 2013 at 3:59pm
Circular dependency is the problem.
Forward declarations are the solution.

http://en.wikipedia.org/wiki/Circular_dependency#Example_of_circular_dependencies_in_C.2B.2B
Topic archived. No new replies allowed.