That looks wrong. If K is nested in H, then I would expect you to define it as:
Code:
template<class T>
class H<T>::K {
public:
K* doSomething();
};
though personally I would just define it within the definition of H. Anyway, once that is fixed, the next problem would be that in H<T>::K, the nested name K depends on the template parameter T. As such, it could, in theory, be interpreted not as a type name, but as an object name, and the rules say that it should be interpreted as a non-type name by default. As such, you should change to:
Code:
template<class T>
typename H<T>::K* H<T>::K::doSomething() {
// ...
}