add main ex02

This commit is contained in:
starnakin 2023-11-22 14:14:03 +01:00
parent dcd70a7091
commit 755af6eee9

60
ex02/src/main.cpp Normal file
View File

@ -0,0 +1,60 @@
#include "MutantStack.hpp"
#include <iostream>
#include <list>
int main()
{
{
std::cout << "Test with MutantStack" << std::endl;
MutantStack<int> l;
l.push(12);
l.push(13);
l.push(14);
l.push(15);
l.push(16);
l.push(17);
std::cout << l.top() << std::endl;
l.pop();
std::cout << l.top() << std::endl;
std::cout << "Size of stack: " << l.size() << std::endl;
MutantStack<int>::iterator it;
MutantStack<int>::iterator const ite = l.end();
for (it = l.begin(); it != ite; ++it) {
std::cout << *it << ' ';
}
std::cout << std::endl;
}
{
std::cout << std::endl <<
"Test with std::list" << std::endl;
std::list<int> l;
l.push_back(12);
l.push_back(13);
l.push_back(14);
l.push_back(15);
l.push_back(16);
l.push_back(17);
std::cout << l.back() << std::endl;
l.pop_back();
std::cout << l.back() << std::endl;
std::cout << "Size of stack: " << l.size() << std::endl;
std::list<int>::iterator it;
std::list<int>::iterator const ite = l.end();
for (it = l.begin(); it != ite; ++it) {
std::cout << *it << ' ';
}
std::cout << std::endl;
}
}