I need to include a .h file that has already been included in another file. Because I cant include the same .h files in two different classes, I am stuck.
The following is an example of what I mean:
Code:
#include "a.h"
int main()
{
AClass aObj;
aObj.someFnct();
return 0;
}
The a.h file
Code:
#include "b.h"
#include "x.h"
class AClass
{
...
...
BClass bObj;
XClass xObj;
void someFnct ();
};
//-------------------------
void AClass::someFnct ()
{
bObj.foo();
...
...
xObj.problemFnct (bObj);
}
The b.h file
Code:
const int MAX = 50;
class BClass
{
int num;
char str[MAX];
...
...
void foo();
};
//-------------------------
void BClass::foo ()
{
AClass aObj; <-- ???
...
...
}
The x.h file
Code:
template <class T>
class XClass
{
...
...
void problemFnct(T &data);
};
//-------------------------
template <class T>
void XClass::problemFnct(T &data);
{
AClass aObj; <-- ???
...
...
aObj.someFnct(); <-- ???
}
How can I call a function or create an object that belongs to AClass from classes B and X