Name Lookup in Nested Class Scope
Normal rules apply for name lookup (§ 7.4.1, p. 283) inside a nested class. Of course, because a nested class is a nested scope, the nested class has additional enclosing class scopes to search. This nesting of scopes explains why we didn’t define line_no
inside the nested version of QueryResult
. Our original QueryResult
class defined this member so that its own members could avoid having to write TextQuery::line_no
. Having nested the definition of our results class inside TextQuery
, we no longer need this typedef
. The nested QueryResult
class can access line_no
without specifying that line_no
is defined in TextQuery
.
As we’ve seen, a nested class is a type member of its enclosing class. Members of the enclosing ...
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.