You’ll have to cast every time you call a method though so it’s not fantastic
It’s a weird design to have a need to store in a structure an element that can be so diverse.
May be if you tell us more about what you are trying to achieve we could discuss if there is a better way to achieve what you are looking for (templates, friend classes, multiple inheritance, pure virtual functions ...) C++ has lots to offer
ams01:
No, they are not related. That is the problem. I'll give it a try with the void*, see what happens. Thanks for the tip, though.
I believe objects in C#/Java all share a common root of type System.Object, but that is not the case with C++.
In C++, at bare minimum an array must include objects that share common type.
Your best approach would be creating a base interface class, and implement the functionalities in the concrete classes.
Then you can create a list of the type of the interface class to store the concrete classes. You can use "dynamic_cast" to cast from the base type to the inherited type.