//--------------------------------------------------------------------
// minover.cpp
//--------------------------------------------------------------------

// Demonstrates function overloading
#include <iostream.h>
// Prototypes for two parameter functions char min ( char x, char y ); // Char parameters double min ( double x, double y ); // Double parameters
// Prototypes for three parameter functions char min ( char x, char y, char z ); // Char parameters double min ( double x, double y, double z ); // Double parameters
void main () { // Call min() with two character arguments. cout << endl << min('A','B') << " has the smaller ASCII value" << endl;
// Call min() with two double-precision arguments. cout << min(10.5,20.0) << " is the smaller number" << endl;
// Call min() with three character arguments. cout << min('B','A','C') << " has the smallest ASCII value" << endl;
// Call min() with three double-precision arguments. cout << min(10.5,20.0,5.5) << " is the smallest number" << endl; }
//--------------------------------------------------------------------
char min ( char x, char y ) // Returns the character with the smaller ASCII value. { char result; // Result returned if ( x < y ) result = x; else result = y; return result; }
//--------------------------------------------------------------------
double min ( double x, double y ) // Returns the smaller of two double-precision values. { double result; // Result returned if ( x < y ) result = x; else result = y; return result; }
//--------------------------------------------------------------------
char min ( char x, char y, char z ) // Returns the character with the smallest ASCII value. { char result; // Result returned if ( x < y ) if ( x < z ) result = x; else result = z; else if ( y < z ) result = y; else result = z; return result; }
//------------------------------------------------------------------
double min ( double x, double y, double z ) // Returns the smallest of three double-precision values. { double result; // Result returned if ( x < y ) if ( x < z ) result = x; else result = z; else if ( y < z ) result = y; else result = z; return result; }