First, I would create a Unit class, and then subclass its units, so you don't need to process a bunch of separate lists. Then I would save the pointers to units in:
std::list< Unit * > unitList
The list allows you to add many objects that you like, and although it does not allow you to quickly access random members of the list, you can easily skip it and not worry about it, trying to move large amounts of memory when you delete something from the middle .
One thing that I like to do is to automatically register a unit with a list of units from within the block constructor. Therefore, assuming Marine is a subclass of Unit, all I would have to do is say:
new Marine(x_pos, y_pos);
... and a new marine will be automatically created and added to the list.
At this point, every frame, you can iterate through each module in unitList and run the device update function (which is a virtual function that is different for each subclass).
After the update cycle, start the cleaning cycle, which is repeated again through unitList, finds all the destroyed units and removes them from the list and removes them.
source share