14.5. Subscript Operator

Classes that represent containers from which elements can be retrieved by position often define the subscript operator, operator[].

Exercises Section 14.4

Exercise 14.20: Define the addition and compound-assignment operators for your Sales_data class.

Exercise 14.21: Write the Sales_data operators so that + does the actual addition and += calls +. Discuss the disadvantages of this approach compared to the way these operators were defined in § 14.3 (p. 560) and § 14.4 (p. 564).

Exercise 14.22: Define a version of the assignment operator that can assign a string representing an ISBN to a Sales_data.

Exercise 14.23: Define an initializer_list assignment operator for your version of the StrVec class.

Exercise 14.24: Decide ...

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.