Hi,

I have a question about the RTTI library typeinfo. I used typeinfo to qurry the type of an int as in the following,

...
#include <typeinfo>
....
int i;
cout << typeid.name();
...

This is suppose to produce int as output but instead I got i, the name of the integer object I declared instead of the name of the type itself (int in this case)

Any expert advice?

Thanks a lot,

from my understanding typeid should be used like this:

int i;
const type_info& info = typeid(i);
cout << "Class name: " << info.name();

hope this helps!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.