mirror of
https://github.com/Ladebeze66/cpp-partie-1.git
synced 2025-12-16 05:58:04 +01:00
48 lines
1.7 KiB
C++
48 lines
1.7 KiB
C++
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* Cat.cpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/12/31 12:52:48 by fgras-ca #+# #+# */
|
|
/* Updated: 2023/12/31 15:26:47 by fgras-ca ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "Cat.hpp"
|
|
|
|
Cat::Cat()
|
|
{
|
|
this->type = "Cat";
|
|
this->brain = new Brain();
|
|
std::cout << GREEN << "Cat default constructor called. Type is set to " << type << "." << RESET << std::endl;
|
|
}
|
|
|
|
Cat::Cat(const Cat ©) : Animal(copy), brain(new Brain(*copy.brain))
|
|
{
|
|
std::cout << CYAN << "Cat copy constructor called. Type is " << type << "." << RESET << std::endl;
|
|
}
|
|
|
|
Cat& Cat::operator=(const Cat &operator_aff)
|
|
{
|
|
Animal::operator=(operator_aff);
|
|
std::cout << MAGENTA << "Cat assignment operator called. Type is now " << type << "." << RESET << std::endl;
|
|
return (*this);
|
|
}
|
|
|
|
Cat::~Cat()
|
|
{
|
|
std::cout << RED << "Cat destructor called. Type was " << type << "." << RESET << std::endl;
|
|
}
|
|
|
|
void Cat::makeSound() const
|
|
{
|
|
std::cout << "Miaouhh! Miaouhh!" << std::endl;
|
|
}
|
|
|
|
Brain* Cat::getBrain(void) const
|
|
{
|
|
return (this->brain);
|
|
}
|