d04 ex02 change pour pouvoir effectuer le test de erlazo

This commit is contained in:
hugogogo
2022-03-12 16:21:56 +01:00
parent 329e38b84b
commit 96e78e34a1
11 changed files with 138 additions and 16 deletions

View File

@@ -0,0 +1,38 @@
# include <iostream>
# include <string>
class Animal {
public:
virtual Animal & operator=( Animal const & rhs ) {
std::cout << "Animal operator=\n";
return *this;
}
};
class Cat : public Animal {
public:
Cat & operator=( Cat const & rhs ) {
Animal::operator=(rhs);
std::cout << "Cat operator=\n";
return *this;
}
Cat & operator=( Animal const & rhs ) {
Animal::operator=(rhs);
std::cout << "Cat operator=\n";
return *this;
}
void catSpeak() {std::cout << "I am a cat\n";}
};
int main() {
Animal* i = new Cat();
Animal* j = new Cat();
i->catSpeak();
j->catSpeak();
*i = *j;
delete i;
delete j;
}