Dog.cpp 2.1 KB

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