home *** CD-ROM | disk | FTP | other *** search
- // ex10020.cpp
- // The read member function
- #include <fstream.h>
-
- class Date {
- int mo, da, yr;
- public:
- Date() { }
- friend ostream& operator<< (ostream& os, Date& dt);
- };
-
- ostream& operator<< (ostream& os, Date& dt)
- {
- os << dt.mo << '/' << dt.da << '/' << dt.yr;
- return os;
- }
-
- main()
- {
- Date dt;
- ifstream tfile("date.dat");
- tfile.read((char *) &dt, sizeof dt);
- cout << dt;
- }