🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2627

Q: RTTI and new??

#2627
From: Michael R. Gile
Date: Fri, 17 Nov 1995 19:10
25 lines
1545 bytes
is there any way to use the typeinfo which is returned from typeid
to create a new object of that type?  I have been looking at the
draft, and this doesn't seem to be possible.  The reason that I ask
is that it is very useful when you have a container full of things
to be able to duplicate the container.  If all of the objects
are not of the same type (maybe they are derived classes), then 
it is not easy to duplicate each object.  Currently, my code gets
around this by making a virtual function for each object that needs
to duplicate itself, but I was hoping that there would be a standard
way to do this now that we have RTTI.  Am I the only one who thinks
that this feature would be incredibly useful?

Thanks in advance.
Mike

-- 
Michael Gile                        |               Graduate Assistant
gilem@rpi.edu                       |   Computer & Systems Engineering
"Don't Blame Me, I voted for Perot!"| Rensselaer Polytechnic Institute

---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <48i6qu$1825@litecdev.eng.rpi.edu>
Path: arc1-ca.pugleaf.net!128.32.155.1!matt

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt
From: gilem@rpi.edu (Michael R. Gile)
Newsgroups: comp.std.c++
Subject: Q: RTTI and new??
Date: 17 Nov 1995 19:10:37 GMT
Organization: Rensselaer Polytechnic Institute
Approved: matt@physics2.Berkeley.EDU (Matt Austern)
Message-ID: <48i6qu$1825@litecdev.eng.rpi.edu>
NNTP-Posting-Host: physics2.berkeley.edu