Starring Sharon Sharalike

Suppose that we have the example program in Figure 10.34 (which is contained in the file refcnt1.cc if you want to print it out).

Figure 10.34. Safe polymorphism: An example program for reference-counting with StockItems (code\refcnt1.cc)

This program doesn't do anything very useful, except to illustrate the constructors and assignment operator, as follows. First, it creates two StockItems, item1 and item2, with specified contents (via the "normal" constructors for undated and dated items, respectively). Then it creates another StockItem, item3, with the same value as that of item1, via the copy constructor. Then ...

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.