7.1.1. Designing the Sales_data Class

Image

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 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.