#include<iostream>
using namespace std;

class Stack {
    protected:
      int st[3];  
    int top;      
      public:
       Stack() 	
       { top = -1; }
       void push(int y) { 
          st[++top] = y; 
       }
       int pop() { 
          return st[top--]; 
       }
};
class Stack2 : public Stack{
    public:
     void push(int x){ 
       if(top >= 3 -1){ 
         cout << "\nError: stack is   full"; 
         exit(1); 
       }
       Stack::push(x); 
     }
     int pop() {   
        if(top < 0) { 
          cout << "\nError: stack is empty"; 
          exit(1); 
        }
        return Stack::pop(); 
     }
};
main(){
    Stack2 s1;
    s1.push(11); s1.push(22);
    s1.push(33);
    cout << s1.pop()<< endl; 
    cout << s1.pop()<< endl;
    cout << s1.pop()<< endl;
    //cout << endl << s1.pop();
    system("pause");   
}

