We help IT Professionals succeed at work.

what is the C++ equivalent of JAVA instanceof ?

ndoung asked
I have a pointer to a C++ base class object. I need to know what is the real class in order to do something.
In JAVA, we can use instanceof to check. I am looking for something equivalent in C++.
Watch Question

There is no an equivalence of Java instanceof in C++.
In C++ you should maybe check with dynamic_cast.
Some compilers allow you to compile with RTTI (run-time type information) embedded into the executable. See http://www.devx.com/getHelpOn/Article/10202/1954 for more info. I know Visual C++ disables RTTI by default (as maintaining RTTI causes performance degradation) but it can be enabled in the project options. I'm not sure if these extensions are part of the C++ standard or compiler-specific extensions.