From 4c13dc84cbd5e1a8fc0b0527d2ccba1f44c1f451 Mon Sep 17 00:00:00 2001 From: kinou-p Date: Fri, 10 Jun 2022 23:03:30 +0200 Subject: [PATCH] half part of cpp01 --- cpp00/ex00/megaphone | Bin 17368 -> 0 bytes cpp01/ex02/Makefile | 33 +++++++++++++++++++++++++++++++++ cpp01/ex02/main.cpp | 31 +++++++++++++++++++++++++++++++ cpp01/ex03/HumanA.cpp | 12 ++++++++++++ cpp01/ex03/HumanA.hpp | 26 ++++++++++++++++++++++++++ cpp01/ex03/HumanB.cpp | 12 ++++++++++++ cpp01/ex03/HumanB.hpp | 25 +++++++++++++++++++++++++ cpp01/ex03/Makefile | 0 cpp01/ex03/Weapon.cpp | 31 +++++++++++++++++++++++++++++++ cpp01/ex03/Weapon.hpp | 26 ++++++++++++++++++++++++++ cpp01/ex03/main.cpp | 31 +++++++++++++++++++++++++++++++ 11 files changed, 227 insertions(+) delete mode 100644 cpp00/ex00/megaphone create mode 100644 cpp01/ex02/Makefile create mode 100644 cpp01/ex02/main.cpp create mode 100644 cpp01/ex03/HumanA.cpp create mode 100644 cpp01/ex03/HumanA.hpp create mode 100644 cpp01/ex03/HumanB.cpp create mode 100644 cpp01/ex03/HumanB.hpp create mode 100644 cpp01/ex03/Makefile create mode 100644 cpp01/ex03/Weapon.cpp create mode 100644 cpp01/ex03/Weapon.hpp create mode 100644 cpp01/ex03/main.cpp diff --git a/cpp00/ex00/megaphone b/cpp00/ex00/megaphone deleted file mode 100644 index ba0d0f21e3dd229155320f05336ec3d35a080501..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17368 zcmeHPeQ;FO6~CJ$5EM4cR}EO$G&7vHFh^si6IEu+tB%<1}^37+SOtOB*Y&{hj;n*}Q$( zZPDqB)0sWY%enV=KJIKGVRRHsgdNCV+ zmx#q;I_lFTX36~)gVdte%JO-I!rkCxS4D*a{F4?em~#(_lU*_DR}C;1>ORP>oQzc6 z$=4{S%vqjmPa|WHCjaL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2P`mRXaA7|D=1MZor$YKm$x(rM^)?pTvI5V=8tH%PJh@)_SukZ@ZC1E5Ze7yP z)Okg}<$3XG>GkLL{UG|I(Wj^b|1$LFP)31f>GS&kFz}`ME@Z6|_*}H`vYJ2gw?jyN zAn~aNCO01~{TTh2E67R~%CFR{mBBt#^QH zQ?&6tfZ~RhHT8vpzsD?;_*4U55qu-?LjG?rg6}HgM}(7R%1q-#O;}9kix_6F5vGih z6!Ih@31eqZqAS#6M9f4oWrWiGBAn>$>xr7th_Ak8ZB1b%%C(3Yp=2_&+la=^v{rO_WMwAos}#>I&4Gwg{u?^P2)2TN)wD>v$v|kjXf?7B)9Gw+E3hLoY1g zH5v(-A>`t0MrR|jxRFjp$=sf!;`hsx6qSZTi8CK9IY;?XsVx}LRKn;+Fen#DHfUwa zOl|HXF!jqI4jqwaoDer_yqq z{&QB8l@CO^G;cX=NIB#&a3&2o#Z!~8iX>VU%$CaUz3`=W_nM(Da5HJ~ZZ5^*$m;47 zzIein`gX?CzP@AvNlxZ&8`PDKAw4h_QBa_vrP>Vb6jHrAl0 zJtv9x3(PfAvXS#^_gcv8_MKRtiI~%SLp$;3I%6#;*zI}$!CYfS#hv!I0{;j0jC}vR zuV%hX+41(m+5Zsaw5Mi!-p?>^qu_$5k5puP-v7pc(Jiw*?|Yc@z8xx(lsm49FQG(x zVz%e~5py0t?mz1>zYq4b$L2ckqnP_uOB`eFzkZ=~I@^B(61)AdW~nmQNoXTy`zIiyy(EW;_a~f(?u-}P zGd}~{N}E0Jr}tI^1hJk~o2)Z_9s-)X+&=HS`TrH*z|iwY#CF`T9|EIW%-O5o?FQAx zf}bC +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2022/06/10 14:10:33 by apommier #+# #+# # +# Updated: 2022/06/10 14:11:06 by apommier ### ########.fr # +# # +# **************************************************************************** # + +NAME = a.out +SRCS = main.cpp +OBJS = ${SRCS:.cpp=.o} +CC = c++ +CFLAGS = -Wall -Wextra -Werror +RM = rm -rf + +${NAME}: ${OBJS} + ${CC} ${LIB} ${OBJS} -o ${NAME} + +all: ${NAME} + +clean: + @${RM} ${OBJS} + +fclean: clean + @${RM} ${NAME} + +re: fclean all + +.PHONY: all clean fclean re \ No newline at end of file diff --git a/cpp01/ex02/main.cpp b/cpp01/ex02/main.cpp new file mode 100644 index 0000000..61ea66e --- /dev/null +++ b/cpp01/ex02/main.cpp @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/10 14:10:35 by apommier #+# #+# */ +/* Updated: 2022/06/10 17:59:29 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include + + +int main() +{ + std::string str = "HI THIS IS BRAIN"; + std::string* stringPTR = &str; + std::string& stringREF = str; + + std::cout << "The memory address of the string variable is | " << &str << std::endl; + std::cout << "The memory address held by stringPTR is | " << stringPTR << std::endl; + std::cout << "The memory address held by stringREF is | " << &stringREF << std::endl; + + std::cout << "The value of the string variable is | " << str << std::endl; + std::cout << "The value pointed to by stringPTR is | " << *stringPTR << std::endl; + std::cout << "The value pointed to by stringREF is | " << stringREF << std::endl; +} \ No newline at end of file diff --git a/cpp01/ex03/HumanA.cpp b/cpp01/ex03/HumanA.cpp new file mode 100644 index 0000000..b5c87af --- /dev/null +++ b/cpp01/ex03/HumanA.cpp @@ -0,0 +1,12 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanA.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/10 21:20:34 by apommier #+# #+# */ +/* Updated: 2022/06/10 21:23:56 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + diff --git a/cpp01/ex03/HumanA.hpp b/cpp01/ex03/HumanA.hpp new file mode 100644 index 0000000..356a1c9 --- /dev/null +++ b/cpp01/ex03/HumanA.hpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanA.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/10 21:20:32 by apommier #+# #+# */ +/* Updated: 2022/06/10 23:01:02 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +class HumanA { + + public: + + HumanA(void); + ~HumanA(void); + + private: + + void attack(void) const; + std::string _name; + std::string *_Weapon; + +}; \ No newline at end of file diff --git a/cpp01/ex03/HumanB.cpp b/cpp01/ex03/HumanB.cpp new file mode 100644 index 0000000..0b73f02 --- /dev/null +++ b/cpp01/ex03/HumanB.cpp @@ -0,0 +1,12 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanB.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/10 21:25:58 by apommier #+# #+# */ +/* Updated: 2022/06/10 21:25:59 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + diff --git a/cpp01/ex03/HumanB.hpp b/cpp01/ex03/HumanB.hpp new file mode 100644 index 0000000..3c1fbef --- /dev/null +++ b/cpp01/ex03/HumanB.hpp @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanB.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/10 21:23:58 by apommier #+# #+# */ +/* Updated: 2022/06/10 23:01:08 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +class HumanB { + + public: + + HumanB(void); + ~HumanB(void); + + private: + + std::string _name; + std::string &_Weapon; + +}; \ No newline at end of file diff --git a/cpp01/ex03/Makefile b/cpp01/ex03/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/cpp01/ex03/Weapon.cpp b/cpp01/ex03/Weapon.cpp new file mode 100644 index 0000000..5b42d11 --- /dev/null +++ b/cpp01/ex03/Weapon.cpp @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Weapon.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/10 21:13:13 by apommier #+# #+# */ +/* Updated: 2022/06/10 21:18:19 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Weapon.hpp" + +Weapon::Weapon(std::string name): _type(name) { + +} + +Weapon::~Weapon() { + +} + +std::string const getType(void) +{ + return (this->_type); +} + +void setType(std::string type) +{ + this->_type = type; +} \ No newline at end of file diff --git a/cpp01/ex03/Weapon.hpp b/cpp01/ex03/Weapon.hpp new file mode 100644 index 0000000..782a49f --- /dev/null +++ b/cpp01/ex03/Weapon.hpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Weapon.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/10 19:43:13 by apommier #+# #+# */ +/* Updated: 2022/06/10 21:13:47 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +class Weapon { + + public: + + Weapon(void); + ~Weapon(void); + std::string const getType(void); + void setType(void); + + private: + + std::string _type; + +}; \ No newline at end of file diff --git a/cpp01/ex03/main.cpp b/cpp01/ex03/main.cpp new file mode 100644 index 0000000..57be118 --- /dev/null +++ b/cpp01/ex03/main.cpp @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/10 20:12:10 by apommier #+# #+# */ +/* Updated: 2022/06/10 20:12:47 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int main() +{ + { + Weapon club = Weapon("crude spiked club"); + HumanA bob("Bob", club); + bob.attack(); + club.setType("some other type of club"); + bob.attack(); + } + { + Weapon club = Weapon("crude spiked club"); + HumanB jim("Jim"); + jim.setWeapon(club); + jim.attack(); + club.setType("some other type of club"); + jim.attack(); + } + return 0; +} \ No newline at end of file