-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDog.cpp
More file actions
44 lines (38 loc) · 727 Bytes
/
Copy pathDog.cpp
File metadata and controls
44 lines (38 loc) · 727 Bytes
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
#include "Dog.hpp"
#include <iostream>
Dog::Dog() : Animal()
{
_type = "Dog";
_brain = new Brain();
std::cout << "Dog constructed" << std::endl;
}
Dog::Dog(const Dog& other) : Animal(other)
{
_brain = new Brain(*other._brain);
std::cout << "Dog copy constructed" << std::endl;
}
Dog& Dog::operator=(const Dog& other)
{
std::cout << "Dog assignment operator called" << std::endl;
if (this != &other)
{
Animal::operator=(other);
if (_brain)
delete _brain;
_brain = new Brain(*other._brain);
}
return *this;
}
Dog::~Dog()
{
delete _brain;
std::cout << "Dog destructed" << std::endl;
}
void Dog::makeSound() const
{
std::cout << "Ouaf !" << std::endl;
}
Brain* Dog::getBrain() const
{
return _brain;
}