aboutsummaryrefslogtreecommitdiff
path: root/cpp01/ex05
diff options
context:
space:
mode:
Diffstat (limited to 'cpp01/ex05')
-rw-r--r--cpp01/ex05/Brain.cpp20
-rw-r--r--cpp01/ex05/Brain.hpp26
-rw-r--r--cpp01/ex05/Human.cpp23
-rw-r--r--cpp01/ex05/Human.hpp28
-rw-r--r--cpp01/ex05/main.cpp21
5 files changed, 118 insertions, 0 deletions
diff --git a/cpp01/ex05/Brain.cpp b/cpp01/ex05/Brain.cpp
new file mode 100644
index 0000000..7ebf969
--- /dev/null
+++ b/cpp01/ex05/Brain.cpp
@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* Brain.cpp :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/02 12:47:24 by cacharle #+# #+# */
+/* Updated: 2020/02/02 16:32:58 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "Brain.hpp"
+
+std::string Brain::identify() const
+{
+ std::stringstream ss;
+ ss << this;
+ return "0x" + ss.str();
+}
diff --git a/cpp01/ex05/Brain.hpp b/cpp01/ex05/Brain.hpp
new file mode 100644
index 0000000..6c1f28b
--- /dev/null
+++ b/cpp01/ex05/Brain.hpp
@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* Brain.hpp :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/02 12:47:22 by cacharle #+# #+# */
+/* Updated: 2020/02/02 16:28:27 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef BRAIN_HPP
+# define BRAIN_HPP
+
+# include <string>
+# include <sstream>
+# include <iostream>
+
+class Brain
+{
+ public:
+ std::string identify() const;
+};
+
+#endif
diff --git a/cpp01/ex05/Human.cpp b/cpp01/ex05/Human.cpp
new file mode 100644
index 0000000..4db0568
--- /dev/null
+++ b/cpp01/ex05/Human.cpp
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* Human.cpp :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/02 12:52:38 by cacharle #+# #+# */
+/* Updated: 2020/02/02 13:08:39 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "Human.hpp"
+
+std::string Human::identify()
+{
+ return brain.identify();
+}
+
+const Brain& Human::getBrain()
+{
+ return brain;
+}
diff --git a/cpp01/ex05/Human.hpp b/cpp01/ex05/Human.hpp
new file mode 100644
index 0000000..6c38ee0
--- /dev/null
+++ b/cpp01/ex05/Human.hpp
@@ -0,0 +1,28 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* Human.hpp :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/02 12:52:39 by cacharle #+# #+# */
+/* Updated: 2020/02/02 13:08:46 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef HUMAN_HPP
+# define HUMAN_HPP
+
+# include "Brain.hpp"
+
+class Human
+{
+ private:
+ const Brain brain;
+
+ public:
+ std::string identify();
+ const Brain& getBrain() ;
+};
+
+#endif
diff --git a/cpp01/ex05/main.cpp b/cpp01/ex05/main.cpp
new file mode 100644
index 0000000..584320a
--- /dev/null
+++ b/cpp01/ex05/main.cpp
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* main.cpp :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/02 12:57:25 by cacharle #+# #+# */
+/* Updated: 2020/02/02 16:27:47 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+# include "Brain.hpp"
+# include "Human.hpp"
+
+int main()
+{
+ Human bob;
+ std::cout << bob.identify() << std::endl;
+ std::cout << bob.getBrain().identify() << std::endl;
+}