51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* Cat.cpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2025/09/06 02:27:27 by aortigos #+# #+# */
|
|
/* Updated: 2025/09/06 02:28:09 by aortigos ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "Cat.hpp"
|
|
|
|
Cat::Cat() : Animal()
|
|
{
|
|
std::cout << "Cat has been created" << std::endl;
|
|
this->type = "Cat";
|
|
this->brain = new Brain();
|
|
}
|
|
|
|
Cat::~Cat()
|
|
{
|
|
std::cout << "Cat has been destroyed" << std::endl;
|
|
delete (this->brain);
|
|
}
|
|
|
|
Cat::Cat(const Cat &other) : Animal(other)
|
|
{
|
|
std::cout << "Cat copied" << std::endl;
|
|
this->brain = new Brain(*other.brain);
|
|
}
|
|
|
|
Cat& Cat::operator=(const Cat &other)
|
|
{
|
|
std::cout << "Cat copy assignment called" << std::endl;
|
|
if (this != &other)
|
|
{
|
|
Animal::operator=(other);
|
|
if (this->brain)
|
|
delete (this->brain);
|
|
this->brain = new Brain(*other.brain);
|
|
}
|
|
return (*this);
|
|
}
|
|
|
|
void Cat::makeSound() const
|
|
{
|
|
std::cout << "Meow!" << std::endl;
|
|
}
|