Ok, i have what i think is a pretty tough problem here, but then again, im still relatively a noob when it comes to c++... Im working on a game that is going to need alot of different unit types. Each one will have different characteristics (different stats), but the basic code for each will be the same (step, draw, fire, etc).
Sure i could make a base class with all of that code, then have other classes inherit the functions, and just set the stats in the constructor, but theres a problem with that. In the game code, i need to loop through all of the units and call their Step or Draw or whatever functions, and i would have to make a separate iterator and loop for each one, but that would just be ugly. To my knowledge, there is no STL container that can hold multiple types, they all seem to be single class templates.
Anyone got a way i could have seperate unit types with different stats, but without all of the ugly code that goes along with a seperate iterators? Thanks in advance!