From a5a197590e45494dc31f0d2fc8fb13194b3975c9 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 2 Feb 2020 18:05:01 +0100 Subject: cpp01 ex05 wip, ex06 --- cpp01/ex05/Brain.cpp | 20 ++++++++++++++++++++ cpp01/ex05/Brain.hpp | 26 ++++++++++++++++++++++++++ cpp01/ex05/Human.cpp | 23 +++++++++++++++++++++++ cpp01/ex05/Human.hpp | 28 ++++++++++++++++++++++++++++ cpp01/ex05/main.cpp | 21 +++++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 cpp01/ex05/Brain.cpp create mode 100644 cpp01/ex05/Brain.hpp create mode 100644 cpp01/ex05/Human.cpp create mode 100644 cpp01/ex05/Human.hpp create mode 100644 cpp01/ex05/main.cpp (limited to 'cpp01/ex05') 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 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 +# include +# include + +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 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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; +} -- cgit