Inside the class, you can omit the class type argument:
template<typename K> struct A { A<K> foo1;
Outside the scope of the class, you need template arguments:
If you declare a member function outside the class, you need a list of templates for the return type and for the class:
// legal template<typename K> A<K> A<K>::bar(A<K> x) { return A<K>(x); } // legal template<typename K> A<K> A<K>::bar(A x) { return A(x); } // illegal! template<typename K> AA::bar(A<K> x) { return A<K>(x); }
source share