I appreciate your reply.
"Hendrik Schober" <
XXXX@XXXXX.COM >wrote in message
Quote
How about using 'std::type_id'? It's sortable (it has
'operator<'), guaranteed to be unique, and will stay
the same for the duration of a process. Or do you really
need a string (as in "a textual description")? Then a
'std::map<std::type_id,std::string>' might be worth
setting up.
Well... so what I'm actually doing is (and please remain seated), I have a
dialog with a TNotebook (well actually it's a TPageControl but for the
purpose of this explanation it's a TNotebook) and I need to display some
different components depending on whatever subclass I'm dealing with. It's a
long and twisted story how it got this way, so don't worry about that. I set
the TNotebook page names to the class names of the subclasses, and I'm using
typeid(*obj).name() to pick the active page. I just needed to be quick and
dirty about it.
But in the end I'm just going to add some GetClassName() base method that
returns the class name (which I'm typing in by hand in each subclass
implementation), and use that instead. Adding methods to these classes is
not incredibly convenient in my situation -- but it's not that hard either
and I won't have to worry about typeid changing.
I know that VCL stuff in particular relies on the RTTI a lot (for example,
the object names in your designer's DFM files -- when you write a new VCL
component you don't define an object name separately, it just uses the class
name from the RTTI to do it), so it seemed like I would be able to safely do
the same -- and it's just so convenient. I don't know. I don't want to put
any more time into thinking about this application right now.
Jason