|
|
1.1 root 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: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.