-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCat.cpp
54 lines (40 loc) · 1.6 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Cat.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dpoveda- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/16 13:19:29 by dpoveda- #+# #+# */
/* Updated: 2022/02/16 18:35:26 by dpoveda- ### ########.fr */
/* */
/* ************************************************************************** */
#include "Cat.hpp"
#include <iostream>
Cat::Cat() {
this->type = "Cat";
this->brain = new Brain();
std::cout << "Cat: Default constructor" << std::endl;
}
Cat::Cat(const Cat& other) {
this->brain = new Brain();
*this = other;
std::cout << "Cat: Copy constructor" << std::endl;
}
Cat::~Cat() {
delete this->brain;
std::cout << "Cat: Destructor" << std::endl;
}
Cat& Cat::operator=(const Cat& other) {
this->Animal::operator=(other);
//this->brain = other.brain; // shallow copy
*this->brain = *other.brain; // deep copy
std::cout << "Cat: Assignment operator" << std::endl;
return *this;
}
void Cat::makeSound() const {
std::cout << "Meow! Meow! Meow!" << std::endl;
}
Brain* Cat::getBrain() const {
return this->brain;
}