To describe my problem, I will assume that we have:
- abstract class Base (with few pure virtual functions).
- classes A, B and C. All inherited from Base. All override pure virtual functions from Base.
Now the problem is in ways to create vector, that can store any of A, B or C object. Well, I know, that I need to create vector of pointers to base class object, like:
std::vector<Base*> list;
But my friend with Apple M1 and clang able to create vector of base class objects (without using pointer) and all fine in his environment. Code:
std::vector<Base> list;
It is very strange for me. I was assuming, vector store objects with equal size per each of them. So all objects in vector must be of the same type, and with pointer all fine, but how it works with instances?