home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / C / ANSICPP.ZIP / EX10015.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-24  |  393 b   |  23 lines

  1. // ex10015.cpp
  2. // Overloading the << operator
  3. #include <iostream.h>
  4.  
  5. class Date {
  6.     int mo, da, yr;
  7. public:
  8.     Date(int m, int d, int y) { mo = m; da = d; yr = y; }
  9.     friend ostream& operator<< (ostream& os, Date& dt);
  10. };
  11.  
  12. ostream& operator<< (ostream& os, Date& dt)
  13. {
  14.     os << dt.mo << '/' << dt.da << '/' << dt.yr;
  15.     return os;
  16. }
  17.  
  18. main()
  19. {
  20.     Date dt(5, 6, 77);
  21.     cout << dt;
  22. }
  23.