Answers to Exercises

1.Here is the new function declaration that needs to be added to the StockItem interface definition (from code\item6.h):
void Write(ofstream& s);

and the one to be added to the Inventory interface definition (from code\invent2.h):

void StoreInventory(ofstream& OutputStream);
2.Figure 6.36 shows the implementation of the Write member function for StockItem, and Figure 6.37 is the implementation of the StoreInventory member function of the Inventory class. As you can see, neither of these functions is tremendously complex or, for that matter, very different from the Display function.
Figure 6.36. The Write member function for the StockItem class (from code\item6.cpp
 void StockItem::Write(ofstream& os) { os << m_Name << ...

Get C++: A Dialog Programming with the C++ Standard Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.