diff --git a/cpp00/ex00/megaphone b/cpp00/ex00/megaphone deleted file mode 100644 index ba0d0f2..0000000 Binary files a/cpp00/ex00/megaphone and /dev/null differ diff --git a/cpp01/ex02/Makefile b/cpp01/ex02/Makefile new file mode 100644 index 0000000..f5a90ab --- /dev/null +++ b/cpp01/ex02/Makefile @@ -0,0 +1,33 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: apommier +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# 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