|
 |
Warp wrote:
> It was you who complained that you have to write a "mySize()" function
> in every single class derived from the base class if you wanted any useful
> information about the actual object.
You said that was a good idea, to prevent bypassing of modularity. :-)
OK, having thought about it, my criticisms in this case aren't really fair.
It isn't reflection, but it's not called reflection, so complaining that it
doesn't do what reflection does isn't too reasonable on my part. It would be
nice if it did, but I understand why it doesn't.
> If you have a virtual function in the class or any of its parent classes,
> you already have RTTI info on it. typeid() itself doesn't add anything to
> the classes.
OK, cool. That's what I thought. (Well, it probably/possibly allocates
space for the strings that name() returns, yes? But that's just one string
per class, so not really a problem.)
> It's also perfectly possible to ask for the typeid of a non-RTTI class
> (ie. one which does not have any virtual functions). In that case you
> simply get the typeid of the parameter (without the runtime checking of
> whether the object is really of that type).
Yeah. And I saw in boost::any they use it to get type information about
things like std::string, which you can't easily add virtual functions to in
order to support doing it yourself.
I guess it has some decent uses.
Thanks for continuing the conversation with me after I ticked you off earlier.
--
Darren New, San Diego CA, USA (PST)
My fortune cookie said, "You will soon be
unable to read this, even at arm's length."
Post a reply to this message
|
 |