Improving the Stock
Class
At this point we need to incorporate the constructors and the destructor into the class and method definitions. Given the significance of adding constructors, we’ll advance the name from stock00.h
to stock10.h
. The class methods go into a file called stock10.cpp
. Finally, we place the program using these resources in a third file, usestok2.cpp
.
The Header File
Listing 10.4 shows the header file for the stock program. It adds prototypes for the constructor and destructor functions to the original class declaration. Also it dispenses with the acquire()
function, which is no longer necessary now that the class has constructors. The file also uses the #ifndef
technique described in Chapter 9 to protect against multiple inclusion ...
Get C++ Primer Plus 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.