D
Dave Theese
Please consider this code:
class base {};
class derived: public base {};
base *ptr = new derived;
cout << typeid(*base).name << endl;
In this case, I see output of "class base" rather than "class derived".
This is somewhat expected I suppose since my base class does not have any
virtual functions and, therefore, I do not have polymorphic classes.
Adding a virtual destructor to base results in output of "class derived", as
expected.
Can somebody more knowledgeable than I please confirm that this is indeed
the exact expected behavior according to the C++ Standard?
Thank you!
class base {};
class derived: public base {};
base *ptr = new derived;
cout << typeid(*base).name << endl;
In this case, I see output of "class base" rather than "class derived".
This is somewhat expected I suppose since my base class does not have any
virtual functions and, therefore, I do not have polymorphic classes.
Adding a virtual destructor to base results in output of "class derived", as
expected.
Can somebody more knowledgeable than I please confirm that this is indeed
the exact expected behavior according to the C++ Standard?
Thank you!