Re: copy constructor

[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by Daniel Longest on April 21, 2001 at 17:03:01:

In Reply to: copy constructor posted by Eric on April 21, 2001 at 16:25:20:

One solution is to implement the copy ctor and = but leave them private so they can't be used. An alternative to this is to use what's called the virtual constructor idiom, which is a way to sort-of use a virtual constructor because such a feature is not directly supported by C++. See the comp.lang.c++ at


: Do we need to implement a copy constructor for our ecosystem?
: I assume the list has a copy constructor defined, so implementing an ecosystem copy constructor would only be used to make a new ecosystem have its own copies of each creature and plant.
: However, I don't see how we can make copies of the creatures in the list without knowing which type of creature each pointer is to call its constructor.
: So do we need to have copy and operator= that go that deep, and if so how do we copy the values of the list pointers without storing type information(which the specs say we can't do)?

Follow Ups:

Post a Followup




Optional Link URL:
Link Title:
Optional Image URL:

[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]