943,914 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 7970
  • C++ RSS
Apr 23rd, 2004
0

RTTI typeinfo question

Expand Post »
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,
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
zhangshi is offline Offline
1 posts
since Apr 2004
Apr 28th, 2004
0

Re: RTTI typeinfo question

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!
Reputation Points: 19
Solved Threads: 0
Light Poster
BlackDice is offline Offline
43 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: need help to debugg this code please!
Next Thread in C++ Forum Timeline: Any better way of implementing this recusively?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC