ex02
This commit is contained in:
43
ex02/MutantStack/MutantStack.hpp
Normal file
43
ex02/MutantStack/MutantStack.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* MutantStack.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/04/21 11:32:08 by aortigos #+# #+# */
|
||||
/* Updated: 2026/04/21 11:32:08 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MUTANTSTACK_HPP
|
||||
# define MUTANTSTACK_HPP
|
||||
|
||||
# include <iostream>
|
||||
# include <stack>
|
||||
|
||||
template <typename T>
|
||||
class MutantStack : public std::stack<T>
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
MutantStack();
|
||||
MutantStack(const MutantStack &other);
|
||||
MutantStack& operator=(const MutantStack &other);
|
||||
~MutantStack();
|
||||
|
||||
typedef typename std::stack<T>::container_type::iterator iterator;
|
||||
typedef typename std::stack<T>::container_type::const_iterator const_iterator;
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
};
|
||||
|
||||
#include "MutantStack.tpp"
|
||||
|
||||
#endif
|
||||
63
ex02/MutantStack/MutantStack.tpp
Normal file
63
ex02/MutantStack/MutantStack.tpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* MutantStack.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/04/21 11:32:08 by aortigos #+# #+# */
|
||||
/* Updated: 2026/04/21 11:32:08 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
template<typename T>
|
||||
MutantStack<T>::MutantStack() : std::stack<T>()
|
||||
{
|
||||
// std::cout << "Span default constructor called" << std::endl;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
MutantStack<T>::MutantStack(const MutantStack &other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
MutantStack<T>& MutantStack<T>::operator=(const MutantStack &other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
std::stack<T>::operator=(other);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
MutantStack<T>::~MutantStack()
|
||||
{
|
||||
// std::cout << "MutantStack destructor called" << std::endl;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename MutantStack<T>::iterator MutantStack<T>::begin()
|
||||
{
|
||||
return (this->c.begin());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename MutantStack<T>::iterator MutantStack<T>::end()
|
||||
{
|
||||
return (this->c.end());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename MutantStack<T>::const_iterator MutantStack<T>::begin() const
|
||||
{
|
||||
return (this->c.begin());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename MutantStack<T>::const_iterator MutantStack<T>::end() const
|
||||
{
|
||||
return (this->c.end());
|
||||
}
|
||||
Reference in New Issue
Block a user