This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: virtual object list
- From: John Love-Jensen <eljay at adobe dot com>
- To: polux moon <polux dot moon at wanadoo dot fr>, <gcc-help at gcc dot gnu dot org>
- Date: Mon, 06 May 2002 10:54:57 -0500
- Subject: Re: virtual object list
You have to use pointers...
list<abstract_class*> myList;
Or... you have to use a reference counting wrapper of your own devising (or
checkout www.boost.org, they probably already have one).
list<ref_ptr<abstract_class> > myList;
Do NOT use the std::auto_ptr (unless you're very, very meticulously
careful). It doesn't have quite the right contract to be used in a STL
container.
list<auto_ptr<abstract_class> > myList; // Probably a Very Bad Thing.
--Eljay
On 5/6/02 10:30 AM, "polux moon" <polux.moon@wanadoo.fr> wrote:
> I can't creat a list (STL) of abstract class object.
> "list<abstract_class> truc;" don't work.
> who can i store abstract class objetc ( in fact non abstract class objet
> which inherits of an abstract class) in a stl list (without using pointers
> if possible)