As an example of file reading and writing it's OK up to a point, but it
won't work if any of the strings contain spaces. operator>>(istream&,
string&) stops when it reaches whitespace.

For robust code it's probably better to define overloaded operators >>
and << for Person, which validate the data and provide some kind of
quoting convention to deal with the problem of embedded spaces etc.

(And it really ought to test for errors on all the file operations.)

As an example of good program design it has flaws in other areas, but I
don't think that was the point of the question.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!