using rtti

M

MoCha

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
 
I

Ivan Vecerina

| 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top