-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCat.cpp
More file actions
executable file
·56 lines (45 loc) · 1011 Bytes
/
Cat.cpp
File metadata and controls
executable file
·56 lines (45 loc) · 1011 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
45
46
47
48
49
50
51
52
53
54
55
56
#include "Cat.hpp"
Cat::Cat()
{
std::cout << "Cat : Constructor called" << std::endl;
this->type = "Cat";
CatBrain = new Brain();
}
Cat::Cat(const Cat& other)
{
std::cout << "Cat : Copy constructor called" << std::endl;
this->type = other.type;
CatBrain = new Brain(*other.CatBrain);
}
Cat& Cat::operator=(const Cat& other)
{
std::cout << "Cat : Copy assignment operator called" << std::endl;
if (this != &other)
{
this->type = other.type;
delete CatBrain;
CatBrain = new Brain(*other.CatBrain);
}
return *this;
}
Cat::~Cat()
{
std::cout << "Cat : Destructor called" << std::endl;
delete CatBrain;
}
// std::string Cat::getType()
// {
// return (this->type);
// }
void Cat::makeSound() const
{
std::cout << "Meoww" << std::endl;
}
std::string Cat::getIdea(int index) const
{
return CatBrain->getIdea(index);
}
void Cat::setIdea(int index, const std::string& idea)
{
CatBrain->setIdea(index, idea);
}