In my program I have a Base class with many inherited classes. I need to store a list of these inherited objects (or any container). The only way I can think of to do this is by having a list of the Base class with some type enumeration and then down casting to the inherited type.
Having to constantly cast my objects seems like a heavy penalty for just trying to have my objects in some container.
Are there any other options? Is casting not as bad as it seems?
Thanks for the help!
Use polymorphism via virtual functions, that’s what they’re there for: