/ CPP_Modules / CPP_Module_04 / ex00 / WrongCat.cpp
WrongCat.cpp
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   WrongCat.cpp                                       :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: gychoi <gychoi@student.42seoul.kr>         +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2023/08/15 16:06:20 by gychoi            #+#    #+#             */
 9  /*   Updated: 2023/08/16 21:53:05 by gychoi           ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include "WrongCat.hpp"
14  #include <iostream>
15  
16  /******************************
17   * Constructor and Destructor *
18   ******************************/
19  
20  WrongCat::WrongCat(void)
21  {
22  	WrongAnimal::type = "WrongCat";
23  	std::cout << "[WrongCat] : Default constructor called" << std::endl;
24  }
25  
26  WrongCat::WrongCat(std::string name) : name(name)
27  {
28  	WrongAnimal::type = "WrongCat";
29  	std::cout << "[WrongCat] : Parameterize constructor called" << std::endl;
30  }
31  
32  WrongCat::~WrongCat(void)
33  {
34  	std::cout << "[WrongCat] : Destructor called" << std::endl;
35  }
36  
37  WrongCat::WrongCat(WrongCat const& target) : WrongAnimal(target)
38  {
39  	std::cout << "[WrongCat] : Copy constructor called" << std::endl;
40  	if (this != &target)
41  		*this = target;
42  }
43  
44  WrongCat&	WrongCat::operator=(WrongCat const& target)
45  {
46  	std::cout << "[WrongCat] : Copy assignment operator called" << std::endl;
47  	if (this != &target) {
48  		this->name = target.name;
49  		WrongAnimal::operator=(target);
50  	}
51  	return *this;
52  }
53  
54  /******************************
55   *      Getter  function      *
56   ******************************/
57  
58  std::string	WrongCat::getType(void) const
59  {
60  	return this->type;
61  }
62  
63  std::string	WrongCat::getName(void) const
64  {
65  	return this->name;
66  }
67  
68  /******************************
69   *   Public Member function   *
70   ******************************/
71  
72  void	WrongCat::makeSound(void) const
73  {
74  	std::cout << "[" << getType() << "] : Don't bark." << std::endl;
75  }