Description
The C++ standard has introduced a number of changes in C++ language semantics. This sample illustrates three of the changes.
Concept
The first example involves friend declarations. From 14.5.3 paragraph 1 in the standard, a friend declaration that does not declare or reference a template instead declares an ordinary non-template function. Without use of the <T>, the function referenced by the friend is treated as a plain function, which is never defined, and therefore a link error results.
The second example accesses a name from the base class. 14.6 paragraph 2 in the standard says that such a name, one that depends on a template parameter (because A22 is derived from A2<T>, which uses the T parameter), is assumed to not be a type name unless typename is used or unless name lookup finds a type (and name lookup is not done in this case until instantiation; see 14.6.2 paragraph 3).
The third case is similar to the second, in that 14.6.2 paragraph 3 says that names from a base class, a class that depends on a template parameter, are not considered by name lookup until instantiation time. Therefore the unqualified references to x and f3() refer to globals. The problem can be remedied by prefacing the references with this->.
Supported
Supported
Supported