Example #1
0
int Stack::Top() const
{
    if(Empty()) {
        throw StackEmptyException();
    } else {
        return this -> head -> info;
    }
}
 T Stack<T>::Pop() 
 {
     try{
         --m_current;                     
         return(m_array[m_current]);  //Throws array excpetions if current index <0
     }
     catch(ArrayException& ex){
         m_current=0;
         throw StackEmptyException(); // throwing StackEmptyException constructor obj -RETHROW
     }
 }
Example #3
0
int Stack::Pop()
{
    if(Empty()) {
        throw StackEmptyException();
    } else {
        SNode *node;
        int res;
        node = this -> head;
        this -> head = node -> next;
        res = node -> info;
        delete node;
        return res;
    }
}
const T& Stack<T,size>::pop() 
{	
	
   
	try
		{
			m_current = m_current -1 ;
			cout << stack_array[m_current] << " is poped out from the stack. \n" << endl;
			return stack_array[m_current];
		}

	catch(ArrayException&)
		{  
			throw StackEmptyException(m_current);
			m_current = 0;
		}
	
	catch(...)
		{
			cout<<"An unhandled exception has occurred \n"<<endl;
		}
	
	
}