Table Of Contents
Previous Section Next Section

Program 53: Maximum Confusion

The max function is simple, the test code is simple, and the answer is .... Well, you figure it out.

  1 /************************************************
  2  * test_max -- Test the max function.           *
  3  ************************************************/
  4 #include <iostream>
  5
  6 /************************************************
  7  * max -- return the larger of two integers.    *
  8  *                                              *
  9  * Returns:                                     *
 10  *      biggest of the two numbers.             *
 11  ************************************************/
 12 const int &max(
 13     const int &i1,      // A number
 14     const int &i2       // Another number
 15 )
 16 {
 17     if (i1 > i2)
 18         return (i1);
 19     return (i2);
 20 }
 21
 22 int main()
 23 {
 24     // I is the biggest of the two expression
 25     const int &i = max(1+2, 3+4);
 26
 27     std::cout <<
 28         "The biggest expression is " <<
 29         i << std::endl;
 30
 31     return (0);
 32 }

(Next Hint 289. Answer 22.)

Table Of Contents
Previous Section Next Section