The purpose of the
Sales_item class is to represent the total revenue, number of copies sold, and average sales price for a book. How these data are stored or computed is not our concern. To use a class, we need not care about how it is implemented. Instead, what we need to know is what operations objects of that type can perform.
Every class defines a type. The type name is the same as the name of the class. Hence, our
Sales_item class defines a type named
Sales_item. As with the built-in types, we can define a variable of a class type. When we write
we are saying that
item is an object of type
Sales_item. We often contract the phrase “an object of type
Sales_item” to “a
Sales_item object” or even ...