Cat.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* Cat.cpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2025/12/18 16:28:27 by bchanot #+# #+# */
  9. /* Updated: 2025/12/18 18:48:50 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "Cat.hpp"
  13. /*
  14. ** ------------------------------- CONSTRUCTOR --------------------------------
  15. */
  16. Cat::Cat() : AAnimal("Cat"), _brain(new Brain())
  17. {
  18. std::cout << "A Cat is born !" << std::endl;
  19. }
  20. Cat::Cat( const Cat & src ) : AAnimal(src), _brain(new Brain(*src._brain))
  21. {
  22. std::cout << "A " << this->type << " is born !" << std::endl;
  23. }
  24. /*
  25. ** -------------------------------- DESTRUCTOR --------------------------------
  26. */
  27. Cat::~Cat()
  28. {
  29. delete this->_brain;
  30. std::cout << "A " << this->type << " has died ..." << std::endl;
  31. }
  32. /*
  33. ** --------------------------------- OVERLOAD ---------------------------------
  34. */
  35. Cat & Cat::operator=( Cat const & rhs )
  36. {
  37. if ( this != &rhs )
  38. {
  39. delete this->_brain;
  40. AAnimal::operator=(rhs);
  41. this->_brain = new Brain(*rhs._brain);
  42. }
  43. return *this;
  44. }
  45. std::ostream & operator<<( std::ostream & o, Cat const & i )
  46. {
  47. (void)i;
  48. //o << "Value = " << i.getValue();
  49. return o;
  50. }
  51. /*
  52. ** --------------------------------- METHODS ----------------------------------
  53. */
  54. void Cat::makeSound(void) const {
  55. std::cout << "*Miaouuu*" << std::endl;
  56. }
  57. /*
  58. ** --------------------------------- ACCESSOR ---------------------------------
  59. */
  60. /* ************************************************************************** */