WrongAnimal.cpp
1 /* ************************************************************************** */ 2 /* */ 3 /* ::: :::::::: */ 4 /* WrongAnimal.cpp :+: :+: :+: */ 5 /* +:+ +:+ +:+ */ 6 /* By: gychoi <gychoi@student.42seoul.kr> +#+ +:+ +#+ */ 7 /* +#+#+#+#+#+ +#+ */ 8 /* Created: 2023/08/15 16:04:05 by gychoi #+# #+# */ 9 /* Updated: 2023/08/16 21:52:56 by gychoi ### ########.fr */ 10 /* */ 11 /* ************************************************************************** */ 12 13 #include "WrongAnimal.hpp" 14 #include <iostream> 15 16 /****************************** 17 * Constructor and Destructor * 18 ******************************/ 19 20 WrongAnimal::WrongAnimal(void) : type("WrongAnimal") 21 { 22 std::cout << "[WrongAnimal] : Default constructor called" << std::endl; 23 } 24 25 WrongAnimal::~WrongAnimal(void) 26 { 27 std::cout << "[WrongAnimal] : Destructor called" << std::endl; 28 } 29 30 WrongAnimal::WrongAnimal(WrongAnimal const& target) 31 { 32 std::cout << "[WrongAnimal] : Copy constructor called" << std::endl; 33 if (this != &target) 34 *this = target; 35 } 36 37 WrongAnimal& WrongAnimal::operator=(WrongAnimal const& target) 38 { 39 std::cout << "[WrongAnimal] : Copy assignment operator called" << std::endl; 40 if (this != &target) 41 this->type = target.type; 42 return *this; 43 } 44 45 /****************************** 46 * Getter function * 47 ******************************/ 48 49 std::string WrongAnimal::getType(void) const 50 { 51 return this->type; 52 } 53 54 /****************************** 55 * Public Member function * 56 ******************************/ 57 58 void WrongAnimal::makeSound(void) const 59 { 60 std::cout << "[" << getType() << "] : **Incomprehensible roars of countless WRONG animals**" << std::endl; 61 }