2 classes holding instances of each other ( but it won't work :( )
From: Gizmo (scottamillard_at_hotmail.com)
Date: 10/29/03
- Next message: Tristan Miller: "Re: C++ to C"
- Previous message: newtothis: "Re: why i++ instead of ++i in for loops"
- Next in thread: Peter van Merkerk: "Re: 2 classes holding instances of each other ( but it won't work :( )"
- Reply: Peter van Merkerk: "Re: 2 classes holding instances of each other ( but it won't work :( )"
- Reply: Christian Jaeger: "Re: 2 classes holding instances of each other ( but it won't work :( )"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 29 Oct 2003 14:16:56 -0000
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
- Next message: Tristan Miller: "Re: C++ to C"
- Previous message: newtothis: "Re: why i++ instead of ++i in for loops"
- Next in thread: Peter van Merkerk: "Re: 2 classes holding instances of each other ( but it won't work :( )"
- Reply: Peter van Merkerk: "Re: 2 classes holding instances of each other ( but it won't work :( )"
- Reply: Christian Jaeger: "Re: 2 classes holding instances of each other ( but it won't work :( )"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|