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
Including two classese in each other
Including two classese in each other
Nov 12, 2011 at 6:43am UTC
jamedadi
(3)
Dear All
Hi
I have two classes A and B. Each class uses the other class in its functions. So I have to include class A in B.h and vice verse.
================================
B.h content
================================
#include "A.h"
.....
================================
A.h content
================================
#include "B.h"
.....
This leads two error. Cloud anyone please help me to solve this problem?
Thank you for your help
Nov 12, 2011 at 7:16am UTC
hamsterman
(4538)
You may want to read
http://cplusplus.com/articles/Gw6AC542/
In short, if you separate declarations and implementations of your classes, you only really need one include. The other can be replaced with a declaration.
Topic archived. No new replies allowed.