-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDog.cpp
More file actions
43 lines (38 loc) · 828 Bytes
/
Copy pathDog.cpp
File metadata and controls
43 lines (38 loc) · 828 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
#include "Dog.hpp"
Dog::Dog()
{
std::cout << "Dog constructor called" << std::endl;
this->type = "Dog";
this->brain = new Brain();
}
Dog::Dog(const Dog ©) : Animal()
{
std::cout << "Dog copy constructor called" << std::endl;
this->type = copy.type;
this->brain = new Brain(*copy.brain);
}
Dog &Dog::operator=(const Dog &src)
{
std::cout << "Dog copy assignment operator called" << std::endl;
this->type = src.type;
delete this->brain;
this->brain = new Brain(*src.brain);
return (*this);
}
Dog::~Dog()
{
std::cout << " Dog destructor called" << std::endl;
delete brain;
}
void Dog::makeSound(void) const
{
std::cout << "YYYaaaaffff YYYYaaaffff I'm a Dog" << std::endl;
}
std::string Dog::getType(void) const
{
return (this->type);
}
Brain &Dog::getBrain(void)
{
return (*this->brain);
}