Original Post
I''m trying to write a GUI. Each GUI object, like buttons, windows, whatever, are specific classes that are all derived from a base GUIObject class.
I keep track of these object with a linked list full of pointers to the class, but they''re all typecast as just pointers to the base class the classes are all derived from.
The base class has a virtual function Draw(). as well as all the other classes. I want it to go through the list and draw all the objects. Heres some code:
while(tempnode != NULL)
{
tempnode->ptr->Draw();
tempnode = tempnode->next;
}
This is the meat of the transversal. tempnode is the current node we''re working with, ptr is a pointer to the base class which should be the same thing (should point to the same thing) as the main class for whatever particular type of object we''re working with, and Draw() is the virtual function in question.
The problem, I get a nice crash when it tries to call this Draw() function. What''s going on?