I've prtogrammed a little game.
it has multiple classes thaht represent multiple objects in the game (player,enemies, walls...).
all the classes are based on a subclass.
all objects are registred in an array of the subclass, so i can acess each object through one array.
with a virtual function called handle.
each class has its own handle.
the Problem is:
the clases have unique attributes like lives or kills.
so far i just added them to the subclass.
but now it seams that it wastes to much memory.
how can i acess to the uniqe attributes, without writing them in the subclass or access the objects directly?
If the attributes are unqiue to their respective classes, you should be adding them to the class, not the subclass.
Does your virtual "handle" function return a pointer to the proper class?
If so, you should be able to access the unique attributes and functions through that pointer.
Posting some code might help in understanding what you're having problems with.