7.1.1. Designing the Sales_data Class


Ultimately, we want Sales_data to support the same set of operations as the Sales_item class. The Sales_item class had one member function1.5.2, p. 23), named isbn, and supported the +, =, +=, <<, and >> operators.

We’ll learn how to define our own operators in Chapter 14. For now, we’ll define ordinary (named) functions for these operations. For reasons that we will explain in § 14.1 (p. 555), the functions that do addition and IO will not be members of Sales_data. Instead, we’ll define those functions as ordinary functions. The function that handles compound assignment will be a member, and for reasons ...

Get C++ Primer, Fifth Edition now with O’Reilly online learning.

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