Shop till You Drop

Now let's continue with our analysis of the class interface ( Figure 6.3). Before we can do anything with an inventory record, we have to enter the inventory data. This means that we need another constructor that actually sets the values into the object. 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 constructor that creates an object with actual data:

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

We can tell that this function is a constructor because its name, StockItem, is the same as the name of the class. If you're a C programmer, you may be surprised to see two ...

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.