How do I get the type of a variable?

0x499602D2 picture 0x499602D2 · Jul 3, 2012 · Viewed 309.3k times · Source

In C++, how does one find the type of a variable?

Answer

Rich O'Kelly picture Rich O'Kelly · Jul 3, 2012

You can use the typeid operator:

#include <typeinfo>
...
cout << typeid(variable).name() << endl;