/** G. Hagopian
3. Write a template class Pair that can hold a pair of values
of any type. Use this to implement a simple symbol table like
the one we used in the calculator (§7.8).
*/
#include<iostream>
#include<vector>
using namespace std;

int Euclid(int m, int n) {
    m = abs(m);
    n = abs(n);
    if(m > n) swap(m,n);  /// m is the smallest
    if(m == 0) return n;
    Euclid(n%m, m);
}

class Rational {
    int numerator;
    int denominator;
public:
    Rational(int n, int d) :
        numerator(n/Euclid(n,d)),
        denominator(d/Euclid(n,d)) {}
    int showNum() const { return numerator;}
    int showDen() const { return denominator; }
    Rational operator*(Rational roper) {
        return(Rational(this->numerator*roper.numerator,
                        this->denominator*roper.denominator));
    }
};

ostream& operator<<(ostream& os, const Rational& r) {
    os << r.showNum() << '/' << r.showDen();
    return os;
}

template<class T, class U>
class Pair {
    T first;
    U second;
public:
    Pair(T t, U u) : first(t), second(u) {}
};

int main() {
    char c{'1'};
    int intgr(12);
    Pair<char, int> p(c,intgr);
    double d = 1.5e-4;
    Rational r(3,4);
    Pair<double, Rational> p2(d,r);
}
