d04 ex01 en grande partie fait mais segfault qqpart

This commit is contained in:
Hugo LAMY
2022-02-25 14:19:24 +01:00
parent 3cdc4ec436
commit 12f4c72e77
16 changed files with 271 additions and 196 deletions

View File

@@ -1,15 +1,20 @@
#include "Cat.hpp"
#define COPLIEN_COLOR B_CYAN
/*********************************************
* CONSTRUCTORS
*********************************************/
Cat::Cat() {
Cat::Cat( Brain * brain ) {
std::cout << COPLIEN_COLOR "Cat constructor" RESET "\n";
type = "cat";
_brain = brain;
return;
}
Cat::Cat( Cat const & src ) {
std::cout << COPLIEN_COLOR "Cat copy constructor" RESET "\n";
*this = src;
return;
}
@@ -19,6 +24,7 @@ Cat::Cat( Cat const & src ) {
*********************************************/
Cat::~Cat() {
std::cout << COPLIEN_COLOR "Cat destructor" RESET "\n";
return;
}
@@ -27,8 +33,9 @@ Cat::~Cat() {
*********************************************/
Cat & Cat::operator=( Cat const & rhs ) {
std::cout << COPLIEN_COLOR "Cat assignator" RESET "\n";
Animal::operator=(rhs);
*_brain = *rhs._brain;
return *this;
}
@@ -39,4 +46,9 @@ Cat & Cat::operator=( Cat const & rhs ) {
void Cat::makeSound() const {
std::cout << "*miaow*\n";
}
void Cat::printBrain() const {
_brain->printIdeas();
}
void Cat::printBrain(int pos) const {
_brain->printIdea(pos);
}