using rtti

Discussion in 'C++' started by MoCha, Nov 26, 2003.

  1. MoCha

    MoCha Guest

    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
     
    MoCha, Nov 26, 2003
    #1
    1. Advertising

  2. "MoCha" <> wrote in message
    news:...
    | 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
     
    Ivan Vecerina, Nov 26, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Harrison

    Re: RTTI

    John Harrison, Jul 14, 2003, in forum: C++
    Replies:
    2
    Views:
    461
    John Harrison
    Jul 14, 2003
  2. Alf P. Steinbach

    Re: RTTI

    Alf P. Steinbach, Jul 14, 2003, in forum: C++
    Replies:
    0
    Views:
    475
    Alf P. Steinbach
    Jul 14, 2003
  3. Steven Lien

    About RTTI

    Steven Lien, Aug 19, 2003, in forum: C++
    Replies:
    4
    Views:
    610
    Ivan Vecerina
    Aug 19, 2003
  4. BillyO
    Replies:
    2
    Views:
    498
    dslater
    Sep 30, 2003
  5. tirath
    Replies:
    3
    Views:
    721
    Ivan Vecerina
    Oct 12, 2003
Loading...

Share This Page