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

  1. #include <stream.hpp>
  2.  
  3. // test level 2 conversions
  4. // the constructor gives an implicit conversion from double to complex
  5.  
  6. class complex {
  7.    double r,i;
  8. public:
  9.    complex (double re= 0.0, double im=0.0)  { r=re; i=im; }
  10.    };
  11.  
  12. overload foo;
  13.  
  14. void foo (int x)
  15. {
  16. cout << "foo(int)\n";
  17. }
  18.  
  19.  
  20. void foo (double d)
  21. {
  22. cout << "foo(double)\n";
  23. }
  24.  
  25.  
  26. void foo (complex c)
  27. {
  28. cout << "foo(complex)\n";
  29. }
  30.  
  31.  
  32. main()
  33. {
  34. int i;
  35. long l;
  36. float f;
  37. double d;
  38. complex c;
  39.  
  40. foo (i);
  41. foo (l);
  42.     // Guidelines gives error: bad argument list.  No code generated.
  43.     // Zortech gave no warnings, and converted to double.
  44. foo (f);
  45. foo (d);
  46. foo (c);
  47. }
  48.