Protection Racket
Member variables and member functions that are listed in a protected section of the interface definition are both treated as though they were private, with one important exception: Member functions of derived classes can access them when they occur as the base class part of a derived class object.
In the current case, we've seen that a DatedStockItem is "just like" a StockItem with one additional member variable and some other additions and changes that aren't relevant here. The important point is that every DatedStockItem contains everything that a StockItem contains. For example, every DatedStockItem has an m_MinimumStock member variable because the StockItem class has an m_MinimumStock member variable, and we're defining ...
Get Learning to Program in C++ 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.