Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Duke Leto

macrumors regular
Original poster
Mar 17, 2008
166
0
I was making my own little clone of an NSView using C++ (to use with GLUT, so that it could be cross-platform), and I made a subclass.

My view class has a getFrame() function, and when I tried to use that function from a subclass, I got an error: "View::getFrame() referenced from:"

The function I referenced it from was the subclass's implementation of draw(), which looked like this:

Code:
void Box::draw()
{
	Rect aFrame = getFrame(); // this is where the problem lies, I think
	GLfloat x = aFrame.origin.x, y = aFrame.origin.y;
	GLfloat width = aFrame.size.width, height = aFrame.size.height;
	glColor3d(drawingColor.red, drawingColor.green, drawingColor.blue);
	glBegin(GL_QUADS);
	glVertex3f(x, y, 1.0f);
	glVertex3f(x+width, y, 1.0f);
	glVertex3f(x+width, y+height, 1.0f);
	glVertex3f(x, y+height, 1.0f);
	glEnd();
}
 

Cinder6

macrumors 6502a
Jul 9, 2009
509
50
My C++ isn't the sharpest, but have you tried replacing getFrame() with View::getFrame() ?
 

Duke Leto

macrumors regular
Original poster
Mar 17, 2008
166
0
Yes, and with Box::getFrame().

If you want to see all the code, I can try to upload it or post it. (So far there is an "NSMutableArray", an "NSEnumerator", and an "NSView".

EDIT::
Woah!!! I am so stupid. I forgot to define getFrame()!
Still, if you want the code, I want to share it. So far the commenting is alright, memory management has not been tested though.
Woohoo! subviews work *with* relative coordinates! I can put a box inside of a box inside of a box!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.