stimpy_z
November 28th, 2002, 05:52 PM
Hello y'all!
Here's a tricky situation. Probably it's quite silly, but I just don't see it (and it's giving me quite a headache)
let's say we have two classes: ClassA and ClassB. We need both classes to interact with eachother so in their private atributes we should find pointers to eachother. The headers should look somehting like...
classa.h
#ifndef __classa_h_
#define __classa_h_
#include "classb.h"
class ClassA {
public:
/* public members here*/
private:
ClassB * ptr_cb;
};
#endif
and...
classb.h
#ifndef __classb_h_
#define __classb_h_
#include "classa.h"
class ClassB {
public:
/* public members here*/
private:
ClassA * ptr_ca;
};
#endif
the trick here is that, no matter where the compiler starts, either one or another ".h" is not reached, so it tells me that either "ClassA" or "ClassB" is not defined.
I know what's going on, but I don't know how to solve it. I can't see a way to make both classes definition see eachother.
Any Ideas?
Steempee
Here's a tricky situation. Probably it's quite silly, but I just don't see it (and it's giving me quite a headache)
let's say we have two classes: ClassA and ClassB. We need both classes to interact with eachother so in their private atributes we should find pointers to eachother. The headers should look somehting like...
classa.h
#ifndef __classa_h_
#define __classa_h_
#include "classb.h"
class ClassA {
public:
/* public members here*/
private:
ClassB * ptr_cb;
};
#endif
and...
classb.h
#ifndef __classb_h_
#define __classb_h_
#include "classa.h"
class ClassB {
public:
/* public members here*/
private:
ClassA * ptr_ca;
};
#endif
the trick here is that, no matter where the compiler starts, either one or another ".h" is not reached, so it tells me that either "ClassA" or "ClassB" is not defined.
I know what's going on, but I don't know how to solve it. I can't see a way to make both classes definition see eachother.
Any Ideas?
Steempee