The Sales_item
class that we used in Chapter 1 is an abstract data type. We use a Sales_item
object by using its interface (i.e., the operations described in § 1.5.1 (p. 20)). We have no access to the data members stored in a Sales_item
object. Indeed, we don’t even know what data members that class has.
Our Sales_data
class (§ 2.6.1, p. 72) is not an abstract data type. It lets users of the class access its data members and forces users to write their own operations. To make Sales_data
an abstract type, we need to define operations for users of Sales_data
to use. Once Sales_data
defines its own operations, we can encapsulate (that is, hide) its data members.