diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-02-02 18:05:01 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-02-02 18:05:01 +0100 |
| commit | a5a197590e45494dc31f0d2fc8fb13194b3975c9 (patch) | |
| tree | f3350feda6ac6549a2b5fc4b45d9ca19f86345d0 /cpp01/ex05 | |
| parent | 7d6a4c877de8048ec5fbea4a563b3d09c8976105 (diff) | |
| download | piscine_cpp-a5a197590e45494dc31f0d2fc8fb13194b3975c9.tar.gz piscine_cpp-a5a197590e45494dc31f0d2fc8fb13194b3975c9.tar.bz2 piscine_cpp-a5a197590e45494dc31f0d2fc8fb13194b3975c9.zip | |
cpp01 ex05 wip, ex06
Diffstat (limited to 'cpp01/ex05')
| -rw-r--r-- | cpp01/ex05/Brain.cpp | 20 | ||||
| -rw-r--r-- | cpp01/ex05/Brain.hpp | 26 | ||||
| -rw-r--r-- | cpp01/ex05/Human.cpp | 23 | ||||
| -rw-r--r-- | cpp01/ex05/Human.hpp | 28 | ||||
| -rw-r--r-- | cpp01/ex05/main.cpp | 21 |
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; +} |
