Could you please post your code?
If you have two classes, lets say A and B that you implemented in four files lets a.h, a.cpp, b.h and b.cpp, then a.h can not include b.h if b.h also includes a.h. I believe this is because the compiler want to fully define all the included definitions before it continues to complete the current file.
So if a.h includes b.h and b.h includes a.h the compiler would try to do something like:
a.h include b.h -> the compiler tries to fully define b.h, what means that it should:
b.h include a.h -> the compiler tries to fully define a.h, what means that it should:
a.h include b.h -> which is not possible until somewhere after infinity.
To overcome this, you can prioritize your includes using forward declaration:
a.h include b.h
b.h forward declare class A
b.cpp include a.h
in code: b.h
1 2 3 4 5 6 7
|
// no including a.h here, instead we do a forward declaration.
// Think of it like a promising "you don't know what class A is yet, but you will know before you have to use it"
class A; // forward declaration of a class that we will refer to but will include later.
class B // start of the scope of class B
{
// function declarations of class B
};
|
in code: b.cpp
1 2 3 4 5 6
|
#include b.h
// first we have to make good on our promise and include a.h
#include a.h
// implementation of class B functions
|