19.5. Nested Classes
A class can be defined within another class. Such a class is a nested class, also referred to as a nested type. Nested classes are most often used to define implementation classes, such as the QueryResult
class we used in our text query example (§ 12.3, p. 484).
Exercise 19.18: Write a function that uses count_if
to count how many empty string
s there are in a given vector
.
Exercise 19.19: Write a function that takes a vector<Sales_data>
and finds the first element whose average price is greater than some given amount.
Nested classes are independent classes and are largely unrelated to their enclosing class. In particular, objects of the enclosing and nested classes are independent from each other. ...
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.