ex02: init without main

This commit is contained in:
starnakin 2023-09-28 11:35:43 +02:00
parent 9c9256631f
commit f03b0d6a42
2 changed files with 67 additions and 0 deletions

26
ex02/Makefile Normal file
View File

@ -0,0 +1,26 @@
CXX := c++
CXXFLAGS := -std=c++98 -Wall -Wextra -Werror -g
SRCDIR := src
OBJDIR := obj
NAME := ex02
SRCS := $(wildcard $(SRCDIR)/*.cpp)
OBJS := $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
all: $(NAME)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
mkdir -p obj
$(CXX) $(CXXFLAGS) -c $< -o $@
$(NAME): $(OBJS)
$(CXX) $(CXXFLAGS) $^ -o $@
clean:
rm -rf $(OBJDIR)
fclean: clean
rm -fr $(NAME)
re: fclean
@make --no-print-directory all

41
ex02/src/MutantStack.hpp Normal file
View File

@ -0,0 +1,41 @@
#pragma once
#include <stack>
template<typename T>
class MutantStack : public std::stack<T>
{
public:
MutantStack<T>() : std::stack<T>()
{
}
MutantStack<T>(MutantStack<T> const& src) :
std::stack<T>(src)
{
}
~MutantStack<T>()
{
}
MutantStack<T>& operator=(MutantStack<T> const& src)
{
if (this == &src)
return *this;
this->c = src.c;
return *this;
}
typedef typename std::deque<T>::const_iterator iterator;
iterator begin() const
{
return this->c.begin();
}
iterator end() const
{
return this->c.end();
}
};