G
Gizmo
hi all
i have a bit of a prob with some 2 classes iv created
if say i have class A and class B.
class A hold an atribute of class B and class be Holds an Atribute of class
A. both are declared as pointers in each others class and iv used #ifndef
in both the .h's of each class.
however c++ does not seem to like me doing this. . .is there any way around
this . . i can do it with one class holding an instance of the other but if
both try to have an instance of each other it throws out loads of errors.
a little example is below
thanks for any help
Giz
#ifndef CLASSA
#define CLASSA
#include "classB.h"
class classA
{
private:
int iSomthing;
classB *B;
public:
int getSomthing();
};
#endif
////////////////////////////////////////////////////////////////////////////
///////////////////
#ifndef CLASSB
#define CLASSB
#include "classA.h"
class classB
{
private :
int iAnotherSomthing;
classA *A;
public :
int GetAnotherSomthing();
};
#endif
i have a bit of a prob with some 2 classes iv created
if say i have class A and class B.
class A hold an atribute of class B and class be Holds an Atribute of class
A. both are declared as pointers in each others class and iv used #ifndef
in both the .h's of each class.
however c++ does not seem to like me doing this. . .is there any way around
this . . i can do it with one class holding an instance of the other but if
both try to have an instance of each other it throws out loads of errors.
a little example is below
thanks for any help
Giz
#ifndef CLASSA
#define CLASSA
#include "classB.h"
class classA
{
private:
int iSomthing;
classB *B;
public:
int getSomthing();
};
#endif
////////////////////////////////////////////////////////////////////////////
///////////////////
#ifndef CLASSB
#define CLASSB
#include "classA.h"
class classB
{
private :
int iAnotherSomthing;
classA *A;
public :
int GetAnotherSomthing();
};
#endif