1.5.1. The Sales_item
Class
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
Sales_item item;
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 ...
Get C++ Primer, Fifth Edition 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.