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

  1. // ex10020.cpp
  2. // The read member function
  3. #include <fstream.h>
  4.  
  5. class Date    {
  6.     int mo, da, yr;
  7. public:
  8.     Date() { }
  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;
  21.     ifstream tfile("date.dat");
  22.     tfile.read((char *) &dt, sizeof dt);
  23.     cout << dt;
  24. }
  25.