typeinfo
#include <typeinfo>
class Animal { };
class Dog : public Animal { };
int main() {
Animal* animal = new Dog;
if (typeid(*animal) == typeid(Dog)) {
cout << "animal is a Dog" << endl;
}
return 0;
}Animal* animal = new Dog;
Dog* dog = dynamic_cast<Dog*>(animal);
if (dog) {
cout << "Animal is a Dog" << endl;
}#include <typeinfo>
if (typeid(int) == typeid(long)) {
cout << "int and long are the same type" << endl;
}