-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDog.cpp
58 lines (47 loc) · 1.66 KB
/
Dog.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Dog.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wcorrea- <wcorrea-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/19 15:44:57 by wcorrea- #+# #+# */
/* Updated: 2023/07/26 09:14:18 by wcorrea- ### ########.fr */
/* */
/* ************************************************************************** */
#include "Dog.hpp"
// Constructors
Dog::Dog(void)
{
std::cout << "Dog default constructor called" << std::endl;
this->type = "Dog";
this->_brain = new Brain();
}
Dog::Dog(Dog const &src) : Animal(src)
{
std::cout << "Dog copy constructor called" << std::endl;
this->_brain = NULL;
*this = src;
}
Dog::~Dog(void)
{
delete this->_brain;
std::cout << "Dog destructor called" << std::endl;
}
// Operators
Dog &Dog::operator=(Dog const &src)
{
std::cout << "Dog assignation operator called" << std::endl;
if (this == &src)
return (*this);
delete this->_brain;
this->_brain = new Brain(*src._brain);
return (*this);
}
// Member functions
void Dog::makeSound(void) const
{
std::cout << "Dog: Woof woof!" << std::endl;
}
// Getters
Brain *Dog::getBrain(void) const {return (this->_brain);}