d04 ex02 change pour pouvoir effectuer le test de erlazo
This commit is contained in:
@@ -49,9 +49,18 @@ Dog::~Dog() {
|
||||
|
||||
Dog & Dog::operator=( Dog const & rhs ) {
|
||||
Animal::operator=(rhs);
|
||||
_brain = new Brain();
|
||||
std::cout << COPLIEN_COLOR "Dog assignator" RESET "\n";
|
||||
if (this != &rhs)
|
||||
_brain = rhs._brain;
|
||||
*_brain = *(rhs.getBrain());
|
||||
return *this;
|
||||
}
|
||||
// need of a second overload in case "Animal cat" = "Animal cat";
|
||||
// https://stackoverflow.com/questions/68248198/why-my-virtual-assignment-operator-not-doing-as-intended
|
||||
Dog & Dog::operator=( Animal const & rhs ) {
|
||||
Animal::operator=(rhs);
|
||||
std::cout << COPLIEN_COLOR "Cat (Animal) assignator" RESET "\n";
|
||||
if (this != &rhs)
|
||||
*_brain = *(rhs.getBrain());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -63,3 +72,4 @@ void Dog::makeSound() const {
|
||||
std::cout << "*woof*\n";
|
||||
}
|
||||
|
||||
Brain * Dog::getBrain() const { return _brain; }
|
||||
|
||||
Reference in New Issue
Block a user