Animal finished

This commit is contained in:
2025-11-09 19:32:22 +01:00
parent 36cce8c388
commit 21a7edfacb
2 changed files with 22 additions and 1 deletions

View File

@@ -22,4 +22,21 @@ Animal::~Animal()
std::cout << "Animal has been destroyed" << std::endl;
}
Animal::Animal(const Animal &other)
{
std::cout << "Animal copied" << std::endl;
*this = other;
}
Animal& Animal::operator=(const Animal &other)
{
std::cout << "Animal copy assignment called" << std::endl;
if (this != &other)
this->type = other.type;
return (*this);
}
void Animal::makeSound() const
{
std::cout << "Animal weird sounds..." << std::endl;
}

View File

@@ -22,7 +22,11 @@ class Animal
std::string type;
public:
Animal();
~Animal();
virtual ~Animal();
Animal(const Animal &other);
Animal& operator=(const Animal &other);
virtual void makeSound() const;
};
#endif