Re: new Class(*this)
On Wed, 2015-04-08, ?? Tiib wrote:
On Thursday, 9 April 2015 01:25:18 UTC+3, Christopher Pisz wrote:
On 4/8/2015 4:01 PM, Doug Mika wrote:
On Wednesday, April 8, 2015 at 2:28:26 PM UTC-6, Doug Mika wrote:
I have the following two classes:
class Fish{
public:
virtual Fish* Clone()=0;
virtual void Swim()=0;
};
....
It is also unwise to implement such methods as "Clone". Silly methods
like those are often carried over from people who want to shape and mold
C++ to be like Java or wherever they came from. We don't need a clone
method, because we already have the means to make a copy...via the copy
constructor:
It is not silly. Sometimes we need dynamic polymorphism in C++.
Undoubtedly ... but the OP is obviously a newbie, and the things
you're talking about is (should be) an advanced and late topic.
I have to agree with Mr Pisz: I sense Java, or Smalltalk, or whatever,
lurking in the background here. Continuing that path is not a good
way to learn how to use C++ well.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .