While reading "Sams teach yourself c++ in 21 days" I cannot understand how does virtual copy constructor work. Full code from book is here: [http://cboard.cprogramming.com/cplusplus-programming/9392-virtual-copy-constructor-help.html][1]
Especially virtual method Clone() calls Mammal copy constructor and Dog copy constructor because it returns "Mammal*" and returns "new dog (*this)"
Mammal::Mammal(const Mammal &rhs):itsAge(rhs.GetAge())
{
cout << "Mammal copy constructor\n";
};
Dog::Dog (const Dog &rhs):Mammal(rhs) //what is ":Mammal(rhs)" here -
// call of Mammal copy constructor?
//if not why is it required?
//or what is it here?
{
cout << "Dog copy constructor\n";
};
And what does return "return new Dog(*this)"? new object or pointer at new object?
Thank you for your answers. P.S. Sorry for my previous answer with wrong tags. It is my first experience of using 'stackoverflow"