Thread: compiling error
View Single Post
Old Oct 30th, 2006, 3:12 AM   #26
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,206
Rep Power: 5 grumpy is on a distinguished road
The reason for your error is that a forward declaration of a class is insufficient to allow declaration of an instance. So;
class Point;

class Rectangle
{
    // other stuff
    Point upLeft;
};
will fail. The way to eliminate it is to ensure that the complete declaration of class Point is seen by the compiler before it reaches the declaration of class Rectangle.

Partially related to your problem is that Point.h #include's Rectangle.h which #include's Point.h ..... That will not loop forever because you have employed #include guards, but is an issue because you will get different behaviour for other source files, depending on whether they #include Point.h or Rectangle.h first.
grumpy is offline   Reply With Quote