Skip to content

Instantly share code, notes, and snippets.

@rchatsiri
Created October 6, 2010 16:39
Show Gist options
  • Save rchatsiri/613640 to your computer and use it in GitHub Desktop.
Save rchatsiri/613640 to your computer and use it in GitHub Desktop.
#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