-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (28 loc) · 797 Bytes
/
Copy pathmain.cpp
File metadata and controls
34 lines (28 loc) · 797 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
#include "Cat.hpp"
#include "Dog.hpp"
#include "WrongCat.hpp"
int main(void)
{
Animal *AnimalArray[6];
for (int i = 0; i < 6; i++)
{
if (i % 2 == 0)
AnimalArray[i] = new Dog();
else
AnimalArray[i] = new Cat();
}
std::cout << "\nDeep copy test!" << std::endl;
Cat cat;
cat.getBrain().setIdea(0, "I LOVE TUNA");
Cat copyCat(cat);
copyCat.getBrain().setIdea(0, "I LOVE SARDINS");
Cat assignCat = cat;
assignCat.getBrain().setIdea(0, "I HATE FISH");
std::cout << "Cat 1: " << cat.getBrain().getIdea(0) << std::endl;
std::cout << "Cat 2: " << copyCat.getBrain().getIdea(0) << std::endl;
std::cout << "Cat 3: " << assignCat.getBrain().getIdea(0) << std::endl;
std::cout << std::endl;
for (int i = 0; i < 6; i++)
delete AnimalArray[i];
return (0);
}