954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

RTTI typeinfo question

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
....
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,

zhangshi
Newbie Poster
1 post since Apr 2004
Reputation Points: 10
Solved Threads: 0
 

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!

BlackDice
Light Poster
43 posts since Apr 2004
Reputation Points: 19
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You