// minValueTemplate.cc  P. Conrad for CISC181, 04/11/07
// illustrate use of function templates.

#include <iostream>
using std::cout;
using std::endl;

#include <string>
using std::string;

template<typename T, typename W>
W minValue(T x, W y)
{
  if (x < y)
    return x;
  else 
    return y;
}

int main(void)
{
   string name1 = "Nathan";
   string name2 = "Laurence";
   string name3 = "Zach";

   int firstResult = minValue( 5, 7 );         // calls int version
   double secondResult = minValue( 6.0, 8.0 ); // calls double version
   char thirdResult = minValue( 't','r' ); // calls char version
   string fourthResult = minValue( name1,name2 ); // calls char version
   string fifthResult = minValue( name1,name3 ); // calls char version

   double sixthResult = minValue(7, 5.0); // calls char version

   cout << "The result of the first call is  :" << firstResult << "\n"
        << "The result of the second call is :" << secondResult << "\n"
        << "The result of the third call is  :" << thirdResult << "\n"
        << "The result of the fourth call is  :" << fourthResult << "\n"
        << "The result of the fifth call is  :" << fifthResult << "\n"
        << "The result of the sixth call is  :" << sixthResult << "\n"
        << endl;    
   
   return 0;  // success

} // end main








