Posted by Daniel Longest on April 18, 2001 at 23:50:02:
In Reply to: Ecosystem constructor posted by Michael Narayan on April 18, 2001 at 21:52:04:
Even though you may never use those, you should design your code with the thought that others might and others for whatever reason might want to make use of those features. What if a user wants to copy by value? Then they'll need a copy constructor. Remeber the rule of 3, if you need a dtor, copy ctor, or =operator that you provide, you probably need all 3. What you could do is make copy ctor and = operator private so they cannot be used but they will be there but IMO you're better off just implementing them and leaving it at that, even if you never use them. It's not very hard to implement them, after all.
: Obviously we need a destructor for our ecosystem since it contains dynamic refrences to creatures (even if those are stored in an STL container). But my question is do we also need a copy constructor and overloaded equals even though there is no chance either would be used.
Post a Followup