home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c031 / 4.ddi / SAMPLES / CPPTUTOR / DEFARG.CP$ / DEFARG
Encoding:
Text File  |  1991-12-12  |  639 b   |  24 lines

  1. // DEFARG.CPP
  2.  
  3. // This is an example program from Chapter 2 of the C++ Tutorial. This
  4. //     program demonstrates default arguments in a function prototype.
  5.  
  6. #include <iostream.h>
  7.  
  8. void show( int = 1, float = 2.3, long = 4 );
  9.  
  10. void main()
  11. {
  12.    show();                // All three arguments default
  13.    show( 5 );             // Provide 1st argument
  14.    show( 6, 7.8 );        // Provide 1st and 2nd
  15.    show( 9, 10.11, 12L ); // Provide all three arguments
  16. }
  17.  
  18. void show( int first, float second, long third )
  19. {
  20.    cout << "\nfirst = "  << first;
  21.    cout << ", second = " << second;
  22.    cout << ", third = "  << third;
  23. }
  24.