An ordinary class may have template member functions. In the following example, the class A declares a template member function called f():
class A{public: template T f(T t);};
You may define the template member function inside the class body, as in:
class A{public: template T f(T t) { return t;}};
Alternatively, you may define it outside the class body. It’s advisable to define the template member function in the same file that contains the class declaration:
class A{public: template T f(T t); // declaration};template T A::f(T t) // definition{ return t;}
You call the template member as follows:
A a;int num=a.f(5);