By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,421 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,421 IT Pros & Developers. It's quick & easy.

using rtti

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"MoCha" <mo**************@rediffmail.com> wrote in message
news:7d**************************@posting.google.c 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
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.