Thread: compiling error
View Single Post
Old Oct 27th, 2006, 1:10 AM   #8
brad sue
Hobbyist Programmer
 
Join Date: Mar 2006
Posts: 120
Rep Power: 3 brad sue is on a distinguished road
Quote:
Originally Posted by The Dark View Post
If you want class Rectangle to be a friend class to Screen, put
friend class Rectangle;
inside screen.
You will need to tell the compiler that Rectangle is a class before you try use it as a friend. This is called forward declaring. Put
class Rectangle;
before the Screen class declaration.

A better idea might be that the Rectangle class should be using the Screen class setPoint member function instead of jumping into the internals of the Screen class.

Also note that this line in setPoint
        pixels[i][j]='c';
Is setting the pixel to the constant 'c', not the value of the c parameter.
Thanks Dark,
but when I put friend class rectangle in Screen, I get a linker error.
[Linker error] undefined reference to `Rectangle::~Rectangle()'
[Linker error] undefined reference to `Point::~Point()'

and the same error that before is not gone.
brad sue is offline   Reply With Quote