I have 2 classes that are causing an issue - Class "A" and Class "B". Class A has to be able to store objects of Class B but a function in Class B must take in arguments of Class A. The code I have is below.
Class A:
#ifndef INC_A
#define INC_A
#include "ClassB.h"
class ClassA
{
private:
ClassB* b;
public:
void Foo()
{
b = new ClassB;
b->Foo2(this);
}
}
#endif
Class B:
#ifndef INC_B
#define INC_B
#include "ClassA.h"
class ClassB
{
public:
void Foo2(ClassA* a)
{
// Do stuff with "a" here
}
}
#endif
The errors I get are below:
'ClassB::Foo2': function does not take 1 arguments
syntax error: identifier 'ClassA'
Is there a way around this seemingly infinite include loop?