RTTI typeinfo question

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2004
Posts: 1
Reputation: zhangshi is an unknown quantity at this point 
Solved Threads: 0
zhangshi zhangshi is offline Offline
Newbie Poster

RTTI typeinfo question

 
0
  #1
Apr 23rd, 2004
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,
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 45
Reputation: BlackDice is an unknown quantity at this point 
Solved Threads: 0
BlackDice's Avatar
BlackDice BlackDice is offline Offline
Light Poster

Re: RTTI typeinfo question

 
0
  #2
Apr 28th, 2004
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!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC