Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > using rtti

Reply
Thread Tools

using rtti

 
 
MoCha
Guest
Posts: n/a
 
      11-26-2003
hi all,
i want to get the name of the class of an object during run-time. the
problem is when i'm using the rtti mechanism of name(), the name is
preceded by the length. So, i get something like 3abc (instead of
abc).
could someone shed some light on this.

thanx
 
Reply With Quote
 
 
 
 
Ivan Vecerina
Guest
Posts: n/a
 
      11-26-2003
"MoCha" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
| i want to get the name of the class of an object during run-time. the
| problem is when i'm using the rtti mechanism of name(), the name is
| preceded by the length. So, i get something like 3abc (instead of
| abc).
| could someone shed some light on this.
The string returned by a typeid's name() member function is
implementation-defined. It could embed information about the
namespace that contains the class in various ways,
and any other information.

So you have two choices with the current C++ standard:
- Use rtti, and unmangle the returned string in
a platform-specific way.
- Add a virtual function to your class, which will
return a name that you can define as needed.


Regards,
Ivan
--
http://ivan.vecerina.com


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[RTTI] cast base class pointer to <templated> derived class pointer tirath C++ 3 10-12-2003 01:44 PM
RTTI versus a base class enum to represent type BillyO C++ 2 09-30-2003 10:21 PM
About RTTI Steven Lien C++ 4 08-19-2003 06:03 PM
Re: RTTI John Harrison C++ 2 07-14-2003 02:36 PM
Re: RTTI Alf P. Steinbach C++ 0 07-14-2003 08:18 AM



Advertisments