23.4.8. Class Transaction

Class Transaction (Figs. 23.2823.29) is an abstract base class that represents the notion of an ATM transaction. It contains the common features of derived classes BalanceInquiry, Withdrawal and Deposit. Figure 23.28 expands upon the Transaction header file first developed in Section 23.3. Lines 13, 17–19 and 22 contain function prototypes for the class’s constructor and four member functions, which we discuss shortly. Line 15 defines a virtual destructor with an empty body—this makes all derived-class destructors virtual (even those defined implicitly by the compiler) and ensures that dynamically allocated derived-class objects get destroyed properly when they are deleted via a base-class pointer. Lines 24–26 declare ...

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.