-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDog.cpp
More file actions
66 lines (57 loc) · 1.88 KB
/
Copy pathDog.cpp
File metadata and controls
66 lines (57 loc) · 1.88 KB
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
59
60
61
62
63
64
65
66
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Dog.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fde-alme <fde-alme@student.42porto.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/09 21:49:52 by fde-alme #+# #+# */
/* Updated: 2025/12/10 19:57:02 by fde-alme ### ########.fr */
/* */
/* ************************************************************************** */
#include "Dog.hpp"
#include <iostream>
Dog::Dog(void) :
Animal("Dog"),
_ideas(new Brain())
{
std::cout << "Dog default constructor called." << std::endl;
}
Dog::Dog(std::string const ideas[]) :
Animal("Dog"),
_ideas(new Brain(ideas))
{
std::cout << "Dog parameterized constructor called." << std::endl;
}
Dog::Dog(std::string const &type, std::string const ideas[]) :
Animal(type),
_ideas(new Brain(ideas))
{
std::cout << "Dog parameterized constructor called." << std::endl;
}
Dog::Dog(Dog const &other) :
Animal(other),
_ideas(new Brain(*other._ideas))
{
std::cout << "Dog copy constructor called." << std::endl;
}
Dog::~Dog(void)
{
delete _ideas;
std::cout << "Dog destructor called." << std::endl;
}
Dog &Dog::operator=(Dog const &other)
{
if (this != &other)
{
Animal::operator=(other);
delete _ideas;
_ideas = new Brain(*other._ideas);
}
std::cout << "Dog copy assignment operator called." << std::endl;
return (*this);
}
void Dog::makeSound() const
{
std::cout << "Woof! Woof!" << std::endl;
}