Created
October 6, 2010 16:39
-
-
Save rchatsiri/613640 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <stdexcept> | |
#include <iostream> | |
#include "Stack.h" | |
template<typename T> | |
const T Stack<T>::pop(){ | |
if(isEmpty()){ | |
throw std::out_of_range("Stack<T> is empty"); | |
} | |
element.pop_back(); | |
return top(); | |
} | |
template<typename T> | |
void Stack<T>::push(T const& value){ | |
element.push_back(value); | |
std::cout<<element.back()<<std::endl; | |
} | |
template<typename T> | |
T Stack<T>::top()const{ | |
if(isEmpty()){ | |
throw std::out_of_range("Stack<T> is empty cannot see on top of stack"); | |
} | |
return element.back(); | |
} | |
template<typename T> | |
bool Stack<T>::isEmpty()const{ | |
return element.empty(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment