A<T> is a class template that introduces a family of classes A based on any typename T. A<int> is an explicit specialization of A<T> - it supersedes the generic class definition. It's no different from having written:
class Aint {
public:
void f();
};
This specialization only has a single member function - f. So when you try to do this:
A<int> obj;
obj.h();
That doesn't compile because A<int> does not have a member function named h. Despite both being named A, A<int> and A<T> are unrelated - one is not a base class of the other, and it doesn't matter what functions and members exist in the general A<T> - the A<int> specialization doesn't have them.
If h is something common, you could move it into a base class:
struct ABase { // or alternatively ABase<T>
void h();
}
template <typename T>
class A : ABase {
void f();
};
template <>
class A<int> : ABase {
void f();
};
That way all of the instantiations of A would have an h(). That is, until somebody goes ahead and adds:
template <>
class A<char> // no inheritance
{
// no h()
};
hfunction elsewhere, e.g. a base class. - interjay