Brain added
This commit is contained in:
47
ex01/Animal/Animal.cpp
Normal file
47
ex01/Animal/Animal.cpp
Normal 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
33
ex01/Animal/Animal.hpp
Normal 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
|
||||
Reference in New Issue
Block a user