diff --git a/ex00/easyfind.hpp b/ex00/easyfind.hpp index 6a02e45..9dc85c4 100644 --- a/ex00/easyfind.hpp +++ b/ex00/easyfind.hpp @@ -1,3 +1,5 @@ +#pragma once + #include template diff --git a/ex01/Span.hpp b/ex01/Span.hpp index 5eb4299..54c0e72 100644 --- a/ex01/Span.hpp +++ b/ex01/Span.hpp @@ -1,3 +1,5 @@ +#pragma once + #include class Span { diff --git a/ex02/Makefile b/ex02/Makefile new file mode 100644 index 0000000..d22e006 --- /dev/null +++ b/ex02/Makefile @@ -0,0 +1,58 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: mmoussou +#include +#include + +template class MutantStack : public std::stack { +public: + MutantStack(void) {} + MutantStack(const MutantStack &cpy) : std::stack(cpy) {} + ~MutantStack(void) {} + + MutantStack &operator=(const MutantStack &cpy) + { + if (this != &cpy) + { + std::stack::operator=(cpy); + } + return *this; + } + + typedef typename std::stack::container_type::iterator iterator; + + iterator begin(void) + { + return std::stack::c.begin(); + } + iterator end(void) + { + return std::stack::c.end(); + } + + typedef typename std::stack::container_type::const_iterator const_iterator; + + const_iterator begin(void) const + { + return std::stack::c.begin(); + } + const_iterator end(void) const + { + return std::stack::c.end(); + } + +private: +}; + diff --git a/ex02/main.cpp b/ex02/main.cpp new file mode 100644 index 0000000..cb89be3 --- /dev/null +++ b/ex02/main.cpp @@ -0,0 +1,28 @@ +#include "MutantStack.hpp" +#include + +int main() +{ + MutantStack mstack; + mstack.push(5); + mstack.push(17); + std::cout << mstack.top() << std::endl; + mstack.pop(); + std::cout << mstack.size() << std::endl; + mstack.push(3); + mstack.push(5); + mstack.push(737); + //[...] + mstack.push(0); + MutantStack::iterator it = mstack.begin(); + MutantStack::iterator ite = mstack.end(); + ++it; + --it; + while (it != ite) + { + std::cout << *it << std::endl; + ++it; + } + std::stack s(mstack); + return 0; +}