Re: forward declaration???


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by Tyler Woods on April 22, 2001 at 16:31:05:

In Reply to: forward declaration??? posted by Heather on April 22, 2001 at 15:56:16:

Hehe, you're screwed.

But for something more constructive...

Forward declarations are used when the following scenerio occurs. Class A has a pointer to Class B. Class B has a pointer to Class A. Both Class A and Class B need the other to be defined before each of them can compile. See the problem? So you add in a:

*******************************************
//Class A.h

class B;

class A
{
...
};

*******************************************

//B.h

class A;

class B
{
...
};

******************************************

All this does is let the compiler know that for Class A, class B WILL be defined, if not now, then later. And the same for class B with class A.

Hope this helps.

Tyler
: Can anyone tell me more about foward declaration?
: or where I can read about it??? I don't recall ever hearing about it....if I use forward declaration of class1 in class 2, then must I include the class1.h in class2.cpp or something? cuz I am getting errors...
: (daiing...the project's due today and mine's not even compiling!!!!!!!!!!!!)
: Thanx ya all





Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]