// minValue2.cc   P.Conrad for CISC181, Spring 2006
// Together with minValue.cc, demonstrates overloaded functions

#include <iostream>

using std::cout;
using std::endl;

// function min for two int values

int minValue( int x, int y ) 
{ 
  cout << "Called minValue with 2 int arguments: " << x << " " << y << endl;
  if (x < y)
    return x;
  else 
    return y;
  
} // end minValue 


//  *********** NOTE ***********
// The difference between using the if/else
// vs. the ternary operator is only a matter of programming style.
//
// The choice to use the ternary op for double and the if/else
// for integers was an arbitrary choice.  I used a different
// approach just to show that both choices are viable.
// We could have used the if/else in both cases, or the ternary
// op in both cases.


// function minValue for double values

double minValue( double x, double y ) 
{ 
  cout << "Called minValue with 2 double arguments: " << x << " "<< y << endl;
  return ( x < y ? x : y ); 

} // end minValue (double version)



int main(void)
{
   int firstResult = minValue( 5, 7 );         // calls int version
   double secondResult = minValue( 6.0, 8.0 ); // calls double version

   // next line invokes an automatic type conversion; look through
   // your textbook for an explanation of how this works!

   double thirdResult = minValue( 9, 3.0);     

   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"
        << endl;    
   
   return 0;  // success

} // end main







