I'm developing a C++ program using visual studio 2010. I've these class definitions & header files :
s.h :
class s : oe {
...
};
t.h :
class t : oe {
...
};
oe.h :
class oe {
...
o getO();//we reference to class 'o' in oe.h, so we must include o.h begore oe.h
};
& o.h :
class o {
...
s getS();//we reference to class 's' in o.h, so we must include s.h begore o.h
};
the problem is that we reference to class 'o' in oe.h
, so we must include o.h
before oe.h
, & also we reference to class 's' in o.h
, so we must include s.h
before o.h
, but we can't do this because s.h
needs oe.h
& oe.h
needs o.h
& o.h
needs s.h
!
As you see, some kind of loop exists in class dependency cycle & so I can't compile the project. If i remove dependency between s.h & t.h & oe.h, the problem will solve (here is stdafx.h
for this state) :
#include "s.h"
#include "t.h"
#include "o.h"
#include "oe.h"
but I have to use all given dependencies & I can't remove anyone of dependencies. any idea?