void Stack<T,size>::push(const T& new_ele) { try { //(when m_current == -1 , Array throws the exception. To push values again indicator should go to 0 th position again.) if (m_current < 0) // if (m_current == -1) m_current = 0; stack_array[m_current] = new_ele; cout << stack_array[m_current] << " is pushed into the stack. \n" << endl; m_current = m_current +1; } catch(ArrayException&) { throw StackFullException(m_current); } catch(...) { cout<<"An unhandled exception has occurred \n"<<endl; } }
void Stack<T>::Push(const T& value) { try{ m_array[m_current]=value; // will throw array exception if index out of bounds. ++m_current; // and current index remains unchanged } catch(ArrayException& ex){ throw StackFullException(); // throwing StackFullException constructor obj -RETHROW } }