0

Here is what I want to do. Say a have a class ClassA so I would have a ClassA.h and and a ClassA.cpp Then I would want a ClassB so I would have a ClassB.h and ClassB.cpp.

Then in the ClassA.h I want to have

class ClassA
{
public:
   ClassA();
private:
   ClassB myB;
}

and in ClassB.h I want to have

class ClassB
{
public:
   ClassB();
private:
   ClassA myA;
}

The problem here is that I need to include ClassB.h in ClassA.h and viceversa which will not compile because it generates an inclusion loop. How can I save this problem?

aarelovich
  • 5,140
  • 11
  • 55
  • 106

0 Answers0