Initializating animal when copying

This commit is contained in:
2025-11-21 11:39:22 +01:00
parent 9735e67e32
commit 45fd66c71c
4 changed files with 9 additions and 9 deletions

View File

@@ -23,7 +23,7 @@ Cat::~Cat()
std::cout << "Cat has been destroyed" << std::endl;
}
Cat::Cat(const Cat &other)
Cat::Cat(const Cat &other) : Animal(other)
{
std::cout << "Cat copied" << std::endl;
*this = other;

View File

@@ -23,7 +23,7 @@ Dog::~Dog()
std::cout << "Dog has been destroyed" << std::endl;
}
Dog::Dog(const Dog &other)
Dog::Dog(const Dog &other) : Animal(other)
{
std::cout << "Dog copied" << std::endl;
*this = other;

View File

@@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Animal.cpp :+: :+: :+: */
/* WrongCat.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/06 02:27:27 by aortigos #+# #+# */
/* Updated: 2025/09/06 02:28:09 by aortigos ### ########.fr */
/* Created: 2025/11/21 11:38:27 by aortigos #+# #+# */
/* Updated: 2025/11/21 11:38:49 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
@@ -23,7 +23,7 @@ WrongCat::~WrongCat()
std::cout << "Cat has been destroyed" << std::endl;
}
WrongCat::WrongCat(const WrongCat &other)
WrongCat::WrongCat(const WrongCat &other) : WrongAnimal(other)
{
std::cout << "WrongCat copied" << std::endl;
*this = other;

View File

@@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Animal.hpp :+: :+: :+: */
/* WrongCat.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/06 02:27:27 by aortigos #+# #+# */
/* Updated: 2025/09/06 02:28:09 by aortigos ### ########.fr */
/* Created: 2025/11/21 11:38:32 by aortigos #+# #+# */
/* Updated: 2025/11/21 11:38:34 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */