Quote:Original post by owl
I can see that now. To me polimorphism in c++ feels a little bit more hackish now than before. I can give virtual functions to a class but they won't be virtual at all when the instance is static. bleh.
Hackish? Why? The language did exactly what one would expect it to do. You had an object of type
cgui_object, so the language correctly chose the
cgui_object::on_draw() implementation when you called
on_draw(). There's nothing hackish about that.
I think you still haven't quite understood what the actual problem is. Since your container holds actual
cgui_object objects rather than pointers to
cgui_object objects, what happened when you tried to put an instance of
cgui_box into the container is that a
cgui_object got copy-constructed from a
cgui_box. Understand? A
__cgui_object__ got constructed, NOT a
cgui_box.
My apologies if I assumed wrong, and you had actually already understood that.