Is it possible to distinguish an STL container from a base type to a derived one? For example, I have two vectors. The first is in the type of the base class, the second is in the type of the Derive class.
class Base
{
};
class Derive : public Base
{
};
Using
vector<Base*>* vec_base = new vector<Base*>;
vector<Derive*>* vec_derive = (vector<Derive*>*)(vec_base);
This is normal? (It works great, but I wanted to get some comments about it). Many thanks.
EDIT: update according to answers.
Say, if I use this vector carefully and don’t use it with multiple inheritance and don’t insert objects other than Derive type, is this normal? (I think it is not)
And thanks for the answers.
source
share