When looking for the declaration of a name used in a template definition, the usual lookup rules (3.4.1, 3.4.2) are used for nondependent names. The lookup of names dependent on the template parameters is postponed until the actual template argument is known (14.6.2).
Section 14.6.2/3 says
In the definition of a class template or a member of a class template, if a base class of the class template depends on a template-parameter, the base class scope is not examined during unqualified name lookup either at the point of definition of the class template or member or during an instantiation of the class template or member.
pos is an non dependent name so the base class is not examined.
So you have two options.
Use fully qualified name of Member i.e base<T>::nestedClass::pos
发布评论
评论(3)
C++03 [第 14.6/8 节] 说
第 14.6.2/3 节说
pos
是一个非依赖名称,因此不检查基类。所以你有两个选择。
base::nestedClass::pos
this->pos
。C++03 [Section 14.6/8] says
Section 14.6.2/3 says
pos
is an non dependent name so the base class is not examined.So you have two options.
base<T>::nestedClass::pos
this->pos
.它必须显式引用为 base::nestedClass::pos [或使用 using 语句]
It has to be explicitly referenced as base::nestedClass::pos [or use a using statement]
您没有将 pos 纳入范围。您可以使用
this->pos += 5;
或usingnestedclass::pos
。You're not bringing pos into scope. You can either use
this->pos += 5;
orusing nestedclass::pos
.