Hello,
I am doing some reading on copy constructors. I know that the compiler will create a default copy constructor.
But what is the real reason that people use copy constructors? This is the code I have been working with. I understand the coding ok.
Many thanks,Code:class Mammal { public: Mammal():itsAge(1) { cout << “Mammal constructor...\n”; } virtual ~Mammal() { cout << “Mammal destructor...\n”; } Mammal (const Mammal & rhs); virtual void Speak() const { cout << “Mammal speak!\n”; } virtual Mammal* Clone() { return new Mammal(*this); } int GetAge()const { return itsAge; } protected: int itsAge; };



LinkBack URL
About LinkBacks




CornedBee