From 442468e3cf91a74e56585f0056346a9765665511 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 10 Feb 2025 10:04:12 +0100 Subject: [PATCH] feat: adding overload on the "=" operator --- cpp04/ex01/Brain.cpp | 6 +++++- cpp04/ex01/Brain.hpp | 4 +++- cpp04/ex01/Dog.cpp | 4 +++- cpp04/ex01/Dog.hpp | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cpp04/ex01/Brain.cpp b/cpp04/ex01/Brain.cpp index dd24df0..3ed559c 100644 --- a/cpp04/ex01/Brain.cpp +++ b/cpp04/ex01/Brain.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/06 15:17:41 by rparodi #+# #+# */ -/* Updated: 2025/02/06 23:28:28 by rparodi ### ########.fr */ +/* Updated: 2025/02/07 17:51:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,3 +25,7 @@ Brain::Brain() { Brain::~Brain() { } + +Brain& Brain::operator=(Brain &value) { + return (value); +} diff --git a/cpp04/ex01/Brain.hpp b/cpp04/ex01/Brain.hpp index 2d0237e..3e7e09a 100644 --- a/cpp04/ex01/Brain.hpp +++ b/cpp04/ex01/Brain.hpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/06 15:17:49 by rparodi #+# #+# */ -/* Updated: 2025/02/06 17:35:51 by rparodi ### ########.fr */ +/* Updated: 2025/02/07 17:51:43 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,11 +14,13 @@ #define BRAIN_HPP #include + class Brain { public: Brain(); ~Brain(); std::string idea[100]; + Brain& operator=(Brain &value); protected: diff --git a/cpp04/ex01/Dog.cpp b/cpp04/ex01/Dog.cpp index 7b8c767..12e0083 100644 --- a/cpp04/ex01/Dog.cpp +++ b/cpp04/ex01/Dog.cpp @@ -6,15 +6,17 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/30 13:40:30 by rparodi #+# #+# */ -/* Updated: 2025/01/31 19:53:02 by rparodi ### ########.fr */ +/* Updated: 2025/02/07 16:04:29 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "Dog.hpp" +#include "Brain.hpp" Dog::Dog() { std::cout << "[Dog]\t\tCreating the class" << std::endl; type = "Dog"; + brain = new Brain(); } Dog::~Dog() { diff --git a/cpp04/ex01/Dog.hpp b/cpp04/ex01/Dog.hpp index 9d67241..ba98c5f 100644 --- a/cpp04/ex01/Dog.hpp +++ b/cpp04/ex01/Dog.hpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/28 17:44:51 by rparodi #+# #+# */ -/* Updated: 2025/01/31 18:24:07 by rparodi ### ########.fr */ +/* Updated: 2025/02/07 17:51:39 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ #define DOG_HPP #include "Animal.hpp" +#include "Brain.hpp" #include class Dog : public Animal { @@ -24,6 +25,7 @@ class Dog : public Animal { protected: private: + Brain *brain; };