Chapter Contents

Previous

Next
631

631



ERROR: Scope for `name' does not match a class template.


Explanation


Explanation

The scope for the name being declared in a template must match a class template or partial specialization. For example:

template <class T, class U> class C {
   class Nested { ... };
   ...
};                                          // primary template for C
template <class T> class <T, int> { ... }; // partial specialization

template <class X, class Y> int C<X, Y>::i = 1; // OK
template <class X, class Y> int C<X, Y>::Nested::i = 1; // OK
template <class X, class Y> int C<Y, X>::j = 0; // Error
template <class X, class Y> int C<Y, int>::k = 7; // Error
template <class X> int C<X, int>::j = 2; // OK
template <class X> int C<X, double>::k = 3; // Error

In other words, to define a member of the primary class template, the template parameters in effect must match the parameters from the template class declaration and the the argument list for the template scope must use the template parameters in the original order. To define a member of a partial specialization the template parameters in effect must match the parameters from the class partial specialization declaration and the the argument list for the template scope must match the class argument list from the partial specialization,


Chapter Contents

Previous

Next

Top of Page

Copyright © 2004 by SAS Institute Inc., Cary, NC, USA. All rights reserved.