The code should be like this:
class A
{};
class B:public A
{};
int main()
{
A* a= new B();
cout<<typeid(a).name()<<endl;
}
output: class A* .
Because type implies the type of the pointer ( which is base*), not the type of the object to which it points.