|
|
Warp wrote:
> that objects could register themselves to some centralized, non-template
> factory, using their own typeid as key, so that the factory could create
> clones of those objects at runtime, based on those typeids.)
Actually, wouldn't this be clearer to do with virtual functions or pointers
to functions anyway? Where does typeid make things better in that scenario?
Isn't it just as easy to do something like
class Alpha : Beta {
....
virtual const char * me() { return "Alpha:Beta"; }
....
}
and switch on that? That even gives you a defined value, so you can (say)
write it into a file and read it back on the next run to reload objects that
serialized themselves or something. Plus, you avoid the overhead of putting
RTTI type_info on *every* class, most of which probably won't be registered
that way?
--
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
|
|