I am working on a home project for a virtual rodeodex that called for the main class, rolodex class and map class. To display the contents of all the "cards" to the console, the destination indicates that main () should call the show (...) function in the rolodex class, passing it ostream and show (...), then iterating over the cards, calling each of its showCard () functions. The actual mapping is performed by the showCard () function of the map object displayed on the provided stream.
I do not understand why ostream should / should be passed anywhere. The job seems to call something like this:
main() {
Rolodex myRolodex;
ostream myStream;
myRolodex.show(myStream);
}
void Rolodex::show(ostream& theStream) {
myCard[i].show(theStream);
}
void Card::show(ostream& theStream) {
theStream << "output some stuff" << endl;
}
instead of the following:
main() {
Rolodex myRolodex;
myRolodex.show();
}
void Rolodex::show() {
myCard[i].show();
}
void Card::show() {
cout << "output some stuff" << endl;
}
ostream , - , ?