home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK4 / SAMPLES / IOSTUTOR / EXIOS114.CP$ / EXIOS114
Encoding:
Text File  |  1991-11-25  |  436 b   |  27 lines

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