/*****************************************************************************************
   Author  : Yan Huang
   Date    : 02.18.07
   Synopsis: implement a tempelate which returns the larger of two given values
             test the template on double, int, and string
******************************************************************************************/

#include <iostream>
#include <string>

template <typename T>
T  larger(T &a, T &b) {
  return (a >= b)? a : b;
}

void main(){
   double d1 = 4.5, d2 = 6.7;
   int i1 = 4, i2 = 7;
   string s1 = "huang", s2 = "yan";

   cout << "The larger of the two doubles: " << d1 << " and " << d2 << " is " << larger(d1, d2) << endl;
   cout << "The larger of the two integers: " << i1 << " and " << i2 << " is " << larger(i1, i2) << endl;
   cout << "The larger of the two string: " << s1 << " and " << s2 << " is " << larger(s1, s2) << endl;
}

