#include<iostream>
using namespace std;
#define MAX 2

class Stack{
     protected:
        int st[MAX];
        int top;
     public:
        Stack(): top(-1)
        { }
        void push(int x){
          st[++top] = x;     
        }               
        int pop(){
          int y;
          y = st[top];
          top--;  
          return y;    
        } 
};
struct coordinate{
       int x;
       int y;
}; 

class PairStack : public Stack{
      public:
         void push(struct coordinate sc){
           if(top == MAX-1){
              cout<<"PairStack is full."<<endl;       
           }
           else{
              Stack::push(sc.x);
              Stack::push(sc.y);      
           }
        }      
        struct coordinate pop(){
            struct coordinate sc;
            sc.x=-1; sc.y= -1; 
            if(top == -1)
                cout<<"PairStack is empty"<<endl;
            else{
               sc.x = Stack::pop();
               sc.y = Stack::pop();  
            }
            return sc;       
      }
};
main(){
    PairStack ps;
    struct coordinate s,s1;
    s.x = 10;
    s.y = 20;
    ps.push(s);
    ps.push(s);
    s1 = ps.pop();
    cout<<s1.x<<" , "<<s1.y<<endl;
    system("pause");
}


