2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by CrazyDieter
0
#include <cstdlib>
#include <iostream>

class Base {
};

class Derived : public Base {};

using namespace std;
int main(void)
{
   Derived* pd = new Derived;
   Base* pb = pd;
   cout << typeid( pb ).name() << endl;   //prints "class Base *"
   cout << typeid( *pb ).name() << endl;   //prints "class Derived"
   cout << typeid( pd ).name() << endl;   //prints "class Derived *"
   cout << typeid( *pd ).name() << endl;   //prints "class Derived"
   
   delete pd;
   
   return EXIT_SUCCESS;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.