nstudent* ps = new
student;
nif (typeid(*ps) ==
typeid(account))
n cout <<"*ps is an account
object" <<endl;
nif (typeid(*ps) ==
typeid(checking))
n cout <<"*ps is a checking
object" <<endl;
nif (typeid(*ps) ==
typeid(student))
n cout <<"*ps is a student
object" <<endl;
nif (typeid(*ps) ==
typeid(savings))
n cout <<"*ps is a savings
object" <<endl;
n
nThe typeid operator is used to check the type of an object against a known type whereas the dynamic_cast operator can be used to check the type of an object against an entire hierarchy.
n