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

  1. #include <stream.hpp>
  2. overload foo;
  3.  
  4. void foo (int x)
  5. {
  6. cout << "foo(int)\n";
  7. }
  8.  
  9.  
  10. void foo (double x)
  11. {
  12. cout << "foo(double)\n";
  13. }
  14.  
  15. void foo (char x)
  16. {
  17. cout << "foo(char)\n";
  18. }
  19. // Guidelines warns: overloading machinism cannot tell a void (int ) from a void (char )
  20. // test gives same result as first.
  21. // Zortech gave no warning message and called foo(char) for second test.
  22.  
  23.  
  24. main()
  25. {
  26. int i;
  27. char c;
  28. float f;
  29.  
  30. foo (i);  // int
  31. foo (c);  // char becomes int
  32. foo (f);  // float becomes double
  33. }
  34.