|
|
| QuotedString.C |
ostream& operator<<(ostream& out, const QuotedString& qs) {
return out << '"' << qs.get() << '"';
} // operator<<
|
| Contact.C |
ostream& operator<<(ostream& out, const Contact& contact) {
return out << '(' <<
QuotedString(contact.get_name()) <<
", " <<
QuotedString(contact.get_address()) <<
')';
} // operator<<
|
![]() | Output formats should usually conform to their
corresponding input formats.
|
![]() | Note that this example fails in this aspect if
the name or the address of a contact contains quotes.
This could be fixed by extending the QuotedString
format with escape sequences.
|
|
| Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 21, 2002 |