-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCat.cpp
58 lines (47 loc) · 1.66 KB
/
Cat.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Cat.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wcorrea- <wcorrea-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/19 15:56:12 by wcorrea- #+# #+# */
/* Updated: 2023/07/19 22:18:19 by wcorrea- ### ########.fr */
/* */
/* ************************************************************************** */
#include "Cat.hpp"
// Constructors
Cat::Cat(void)
{
std::cout << "Cat default constructor called" << std::endl;
this->type = "Cat";
this->_brain = new Brain();
}
Cat::Cat(Cat const &src) : Animal(src)
{
std::cout << "Cat copy constructor called" << std::endl;
this->_brain = NULL;
*this = src;
}
Cat::~Cat(void)
{
delete this->_brain;
std::cout << "Cat destructor called" << std::endl;
}
// Operators
Cat &Cat::operator=(Cat const &src)
{
std::cout << "Cat assignation operator called" << std::endl;
if (this == &src)
return (*this);
delete this->_brain;
this->_brain = new Brain(*src._brain);
return (*this);
}
// Member functions
void Cat::makeSound(void) const
{
std::cout << "Cat: Meow meow!" << std::endl;
}
// Getters
Brain *Cat::getBrain(void) const {return (this->_brain);}