More about the StockItem class Interface

Now let's continue with our analysis of the class interface for the StockItem class (Figure 6.3 on page 312). Before we can do anything with a StockItem object, we have to enter the inventory data for that object. This means that we need another constructor that actually sets the values into a StockItem. We also need some way to display the data for a StockItem on the screen, which means writing a Display function.

The next line of that figure is the declaration of the “normal” constructor that creates an object with actual data:

StockItem(std::string Name, short InStock, short Price, std::string Distributor, std:
:string UPC);

We can tell that this function is a constructor because its name, StockItem ...

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.