View Full Version : 2 textbook classess reference each other within their declarations, how to compile???

01-06-2002, 01:48 PM
OK, as you can see. these two classes each require the other to be declareded in order to declare itself. i found these in a text book. there must be some way to make them compile. but as is they will not under any circumstances beknownst by my self. i don't understand why they won't compile. if you reverse their ordinal positions then they present the exact opposite errors. surely their is a simple solution. please advise if you can asap. i have to start spring semester tomorrow. i'll apreciate it so much. thanks


//@@@@@@@@@@@@@@@@@@@@@ GeomObj class @@@@@@@@@@@@@@@@
class GeomObj{

IntRect scrnExtnt;
Cuboid genBoxExtent,worldBoxExtent;
SphereInfo genSphereExtent,worldSphereExtent;
GeomObj * next;
GeomObj(): next(NULL){}
virtual bool hit(Ray &r, Intersection &inter); //<<<<<<< WARNING
virtual void loadStuff();
virtual void drawOpenGL();
virtual void tellMaterialsGL();
virtual void makeExtentPoints(PointCluster& clust);
virtual Point2 texturePoint(Point3 p);
virtual Color3 texture(HitInfo& h);

//@@@@@@@@@@@@@@@@@@@@ Ray @@@@@@@@@@@@@@@@@@@@@@@@@
class Ray{
Point3 start;
Vector3 dir;
int recurseLevel;
int row, col; // for screen extents
int numInside; // number of objects on list
GeomObj* inside[10]; // array of object pointers

Ray(Point3 origin); //constructor: set start point of ray
Ray(Point3& origin, Vector3& direction);
void setStart(Point3& p);
void setDir(float x, float y, float z);
void setRayDirection(Light *L); //for shadow feelers
void setRayDirection(Vector3& dir); //for spawned rays
int isInShadow();
void makeGenericRay(GeomObj* p, Ray& gr);

[This message has been edited by wildeyedboyfromfreecloud (edited 01-06-2002).]

01-06-2002, 02:06 PM
1) this is not opengl-related but c++-related
2) this is certainly not an advanced question and should be posted at the beginners forum

here is the solution anyway:

class GeomObj;
class Ray;

class GeomObj {

class Ray {