cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
#include h files
#include h files
May 22, 2013 at 3:55pm UTC
Edward01
(87)
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 UTC
MrHutch
(1822)
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 UTC
Catfish4
(666)
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.