Prototype of a prototype?

Started by
3 comments, last by GameDev.net 18 years, 1 month ago
Okay. I have class B which I want to incorporate previously declared class A into. All well and good. But, how would I put a pointer to a class B into class A, without getting a compiler error?
Advertisement
Quote:Original post by Erondial
Okay. I have class B which I want to incorporate previously declared class A into. All well and good. But, how would I put a pointer to a class B into class A, without getting a compiler error?


Forward declare:
class B; // Forward declareclass A {private:     B *m_pB;};class B {private:     A *m_pA;};

Note this only works for pointers/references.
hi,

you can use class forward declaration,


write only above class A:

class B;

class A
{
...
}

and before class B:

class A;

class B
{
...
}




Marc
Yes, use a forward declaration.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
damn,
half of a minute to late ^^


Marc

This topic is closed to new replies.

Advertisement