Defining the Members of a Nested Class

In this version, we did not define the QueryResult constructor inside the class body. To define the constructor, we must indicate that QueryResult is nested within the scope of TextQuery. We do so by qualifying the nested class name with the name of its enclosing class:

// defining the member named QueryResult for the class named QueryResult// that is nested inside the class TextQueryTextQuery::QueryResult::QueryResult(string s,                shared_ptr<set<line_no>> p,                shared_ptr<vector<string>> f):        sought(s), lines(p), file(f) { }

Reading the name of the function from right to left, we see that we are defining the constructor for class QueryResult, which is nested in the scope of ...

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.