This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ming Now we don't need the Write() member
function (although << could call it).
<< Applied Programming OK. We're on a roll. Let's try input.
We'll have a function like We can just say friend istream& operator>>(istream&, type&);
friend istream TimeType t(10,20,30);
cout << "The time is " << t << endl;
endl for each built-in. and get What does it have to do? The time is 10:20:30 Convert text characters to the type.
Applied Programming Suppose we want to input TimeType iin exactly
the same way as we are outputting them – three
integers separated by :
istream& operator>>(istream& is,
char temp; Of course, this assumes that input is correct.
A final version would require error checking.
Should an error occur, error flags should be
turned on and the stream should not be returned
– just as...
View Full Document
- Spring '14