home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 5.ddi / OVLOAD.ZIP / OV2B.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-15  |  550 b   |  35 lines

  1. #include <stream.h>
  2. overload foo;
  3.  
  4. void foo (char x)
  5. {
  6. cout << "foo(char)\n";
  7. }
  8.  
  9.  
  10. void foo (int x)
  11. {
  12. cout << "foo(int)\n";
  13. }
  14.  
  15. // warning that overloading mechanism cannot tell void(char ) from void(int )
  16.  
  17. void foo (double x)
  18. {
  19. cout << "foo(double)\n";
  20. }
  21.  
  22. main()
  23. {
  24. int i;
  25. char c;
  26. float f;
  27.  
  28. foo (i);  // int becomes char with no warning
  29. foo (c);  // char
  30. foo (f);  // float becomes double
  31. }
  32.  
  33. // This test and test 2 indicates that when the functions cannot be
  34. // distinguished on "exact match", the first one is used.
  35.