diff --git a/ex01/Cat/Cat.cpp b/ex01/Cat/Cat.cpp index a2a51c4..4b3d60d 100644 --- a/ex01/Cat/Cat.cpp +++ b/ex01/Cat/Cat.cpp @@ -28,8 +28,7 @@ Cat::~Cat() Cat::Cat(const Cat &other) : Animal(other) { std::cout << "Cat copied" << std::endl; - this->brain = NULL; - *this = other; + this->brain = new Brain(*other.brain); } Cat& Cat::operator=(const Cat &other) diff --git a/ex01/Dog/Dog.cpp b/ex01/Dog/Dog.cpp index abf6aad..dd81f2f 100644 --- a/ex01/Dog/Dog.cpp +++ b/ex01/Dog/Dog.cpp @@ -28,8 +28,7 @@ Dog::~Dog() Dog::Dog(const Dog &other) : Animal(other) { std::cout << "Dog copied" << std::endl; - this->brain = NULL; - *this = other; + this->brain = new Brain(*other.brain); } Dog& Dog::operator=(const Dog &other) diff --git a/ex01/WrongAnimal/WrongAnimal.cpp b/ex01/WrongAnimal/WrongAnimal.cpp index 5573a0b..010efc6 100644 --- a/ex01/WrongAnimal/WrongAnimal.cpp +++ b/ex01/WrongAnimal/WrongAnimal.cpp @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* Animal.cpp :+: :+: :+: */ +/* WrongAnimal.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aortigos brain = NULL; - *this = other; + this->brain = new Brain(*other.brain); } Cat& Cat::operator=(const Cat &other) diff --git a/ex02/Dog/Dog.cpp b/ex02/Dog/Dog.cpp index abf6aad..dd81f2f 100644 --- a/ex02/Dog/Dog.cpp +++ b/ex02/Dog/Dog.cpp @@ -28,8 +28,7 @@ Dog::~Dog() Dog::Dog(const Dog &other) : Animal(other) { std::cout << "Dog copied" << std::endl; - this->brain = NULL; - *this = other; + this->brain = new Brain(*other.brain); } Dog& Dog::operator=(const Dog &other) diff --git a/ex02/WrongAnimal/WrongAnimal.cpp b/ex02/WrongAnimal/WrongAnimal.cpp index 5573a0b..13850d9 100644 --- a/ex02/WrongAnimal/WrongAnimal.cpp +++ b/ex02/WrongAnimal/WrongAnimal.cpp @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* Animal.cpp :+: :+: :+: */ +/* WrongAnimal.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aortigos type = "WrongCat"; } WrongCat::~WrongCat() { - std::cout << "Cat has been destroyed" << std::endl; + std::cout << "WrongCat has been destroyed" << std::endl; } WrongCat::WrongCat(const WrongCat &other) : WrongAnimal(other) diff --git a/ex02/WrongCat/WrongCat.hpp b/ex02/WrongCat/WrongCat.hpp index a383995..3d37eb8 100644 --- a/ex02/WrongCat/WrongCat.hpp +++ b/ex02/WrongCat/WrongCat.hpp @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* Animal.hpp :+: :+: :+: */ +/* WrongCat.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aortigos