#include<iostream>
using namespace std;
#define MAX 10

class Distance{
   private:
       int feet;
       float inches;
   public:
       Distance():feet(0), inches(0)
       { }
       Distance(int f, float i): feet(f), inches(i)
       { }
       void showDist(){
          cout<<feet<<" : "<<inches<<endl;     
       }                  
};

template <class Type, int size>
class Stack  {
  private:
    Type st[size]; 
    int top;             
  public:
    Stack() { 
      top = -1; 
    }
    void push(Type var) {    
      st[++top] = var; 
    }
    Type pop() { 
      return st[top--]; 
    }
};

main() {
   Stack<Distance, 3> s;
   Distance d1(1, 2);
   Distance d2(2, 3);
   Distance d3(3, 4);
   s.push(d1);
   s.push(d2);
   s.push(d3);
   (s.pop()).showDist();
   (s.pop()).showDist();
   (s.pop()).showDist(); 
       
  Stack<float, 3> s1; 
  s1.push(111.1);   s1.push(222.2);
  s1.push(333.3);
  cout << "1: " << s1.pop() << endl;
  cout << "2: " << s1.pop() << endl;
  cout << "3: " << s1.pop() << endl;
  Stack<long, 4> s2; 
  s2.push(123123123); 
  s2.push(234234234);
  s2.push(345345345);
  cout << "1: " << s2.pop() << endl;
  cout << "2: " << s2.pop() << endl;
  cout << "3: " << s2.pop() << endl;
  Stack<char, 4> s3; 
  s3.push('a'); 
  s3.push('b');
  s3.push('c');
  cout << "1: " << s3.pop() << endl;
  cout << "2: " << s3.pop() << endl;
  cout << "3: " << s3.pop() << endl;
  
  system("pause"); 
}

