POV-Ray : Newsgroups : povray.off-topic : Standard libraries : Re: Standard libraries Server Time
6 Sep 2024 09:18:47 EDT (-0400)
  Re: Standard libraries  
From: Warp
Date: 8 Mar 2009 20:47:17
Message: <49b46714@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> 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"; }
>     ....
> }

  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. I thought you wanted some way of
distinguishing the actual object without having to implement a function
in each class.

> Plus, you avoid the overhead of putting 
> RTTI type_info on *every* class, most of which probably won't be registered 
> that way?

  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.

  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).

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.