Download this source file


// MaxDeflt.cpp - A program to show an default arguments to functions.
//
// Written by: Wayne Pollock, Tampa Florida 1999

#include <iostream>

int max (int x, int y = 0)
{
   if ( x > y )
      return x;
   else
      return y;
}

int main ()
{
   int i = 5, j = 12;

   cout << "max(" << i << ", " << j
        << ") = " << max( i, j ) << ".\n" << endl;

   cout << "max(5) = " << max( 5 ) << ".\n" << endl;
   cout << "max(-5) = " << max( -5 ) << "." << endl;

   return 0;
}