home *** CD-ROM | disk | FTP | other *** search
/ Microsoftware Monthly 19…2 Programming Power Tools / MASO9512.ISO / cpptutor / cpptutor.arj / EXAMPLES / EX1210.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-27  |  814 b   |  37 lines

  1. // \EXAMPLES\EX1210.CPP
  2.  
  3. #include <iostream.h>
  4.  
  5. void f() {
  6.    cout << "You called f() with no arguments." << endl;
  7. }
  8.  
  9. void f(int i) {
  10.    cout << "You called f(int): " << i << endl;
  11. }
  12.  
  13. void f(float i, int j) {
  14.    cout << "You called f(float, int) " << i
  15.    << ",  " << j << endl;
  16. }
  17.  
  18. void f(int i, float j) {
  19.    cout << "You called f(int, float) " << i
  20.    << ", " << j << endl;
  21. }
  22.  
  23. void main() {
  24.    int i = 3;
  25.    short k = 5;
  26.    float fl = 3.14;
  27.    double dl = 1.33;
  28.    f();             // invokes f()
  29.    f(i);            // invokes f(int)
  30.    f(fl);           // invokes f(int)
  31.    f(i, fl);        // invokes f(int, float)
  32.    f(fl, i);        // invokes f(float, int)
  33.    f(dl, k);        // invokes f(float, int)
  34.    //f(i, j);       // ambiguous: f(int, float) or f(float, int)
  35.  
  36. }
  37.