Brain added

This commit is contained in:
Angel Ortigosa Perez
2025-11-10 11:47:40 +01:00
parent 5ab7e97c1e
commit a6f3e7ea31
14 changed files with 526 additions and 0 deletions

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

33
ex01/Animal/Animal.hpp Normal file
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 ANIMAL_HPP
# define ANIMAL_HPP
# include <iostream>
class Animal
{
protected:
std::string type;
public:
Animal();
virtual ~Animal();
Animal(const Animal &other);
Animal& operator=(const Animal &other);
virtual void makeSound() const;
std::string getType() const;
};
#endif