d04 ex00 gestion virtual destructor et ajout messages constructors et destructors

This commit is contained in:
Hugo LAMY
2022-02-24 17:59:05 +01:00
parent ba3b88f0bf
commit 3cdc4ec436
29 changed files with 570 additions and 0 deletions

51
d04/ex00/Animal.cpp Normal file
View File

@@ -0,0 +1,51 @@
#include "Animal.hpp"
#define COPLIEN_COLOR B_CYAN
/*********************************************
* CONSTRUCTORS
*********************************************/
Animal::Animal() {
std::cout << COPLIEN_COLOR "Animal constructor" RESET "\n";
type = "animal";
return;
}
Animal::Animal( Animal const & src ) {
std::cout << COPLIEN_COLOR "Animal copy constructor" RESET "\n";
*this = src;
return;
}
/*********************************************
* DESTRUCTORS
*********************************************/
Animal::~Animal() {
std::cout << COPLIEN_COLOR "Animal destructor" RESET "\n";
return;
}
/*********************************************
* OPERATORS
*********************************************/
Animal & Animal::operator=( Animal const & rhs ) {
if ( this != &rhs )
{
type = rhs.getType();
}
return *this;
}
std::string Animal::getType() const {return type;}
/*********************************************
* PUBLIC MEMBER FUNCTIONS
*********************************************/
void Animal::makeSound() const {
std::cout << "*sound*\n";
}