Well, there are two cases that need to be considered. In database.cc at line 71,
cout << *i1 << endl; and at line 83
output << *i1 << " ";
The main difference is one is sending the details to
cout, the other to the file
output. (There is also the fact that one has
endl and the other
" ", which is relatively simple to deal with).
One of my suggestions was to replace those two lines with
i1->print(cout); and
i1->print(output);
To do that, add to the class Passenger the public function declaration
|
void print(std::ostream & os);
|
and then add the function definition, something like this:
1 2 3 4
|
void Passenger::print(std::ostream & os)
{
os << fname << ' ' << lname << ' ' << destination << '\n';
}
|
If you like you could remove the
<< '\n' from function print() and use a separate cout/output statement to output whatever is required afterwards.
I think that's all.
Though I do have suggestion number four, which would be to add to the Passenger class a member function
std::string toString() which would return a string containing the three data items suitably spaced in a single string.
Then instead of
cout << *i1 << endl;
you might have
cout << i1->toString() << endl;