This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]