Project finished

This commit is contained in:
Angel Ortigosa Perez
2025-11-10 11:18:08 +01:00
parent d893207a3c
commit 5ab7e97c1e
6 changed files with 179 additions and 11 deletions

View File

@@ -0,0 +1,47 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Animal.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 */
/* */
/* ************************************************************************** */
#include "WrongAnimal.hpp"
WrongAnimal::WrongAnimal() : type("WrongAnimal")
{
std::cout << "Animal has been created" << std::endl;
}
WrongAnimal::~WrongAnimal()
{
std::cout << "Animal has been destroyed" << std::endl;
}
WrongAnimal::WrongAnimal(const WrongAnimal &other)
{
std::cout << "WrongAnimal copied" << std::endl;
*this = other;
}
WrongAnimal& WrongAnimal::operator=(const WrongAnimal &other)
{
std::cout << "WrongAnimal copy assignment called" << std::endl;
if (this != &other)
this->type = other.type;
return (*this);
}
void WrongAnimal::makeSound() const
{
std::cout << "WrongAnimal weird sounds..." << std::endl;
}
std::string WrongAnimal::getType() const
{
return (this->type);
}

View File

@@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Animal.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 */
/* */
/* ************************************************************************** */
#ifndef WRONGANIMAL_HPP
# define WRONGANIMAL_HPP
# include <iostream>
class WrongAnimal
{
protected:
std::string type;
public:
WrongAnimal();
~WrongAnimal();
WrongAnimal(const WrongAnimal &other);
WrongAnimal& operator=(const WrongAnimal &other);
void makeSound() const;
std::string getType() const;
};
#endif