Hi, I have below code.
template <class T>
class Test
{
public:
template<class T>
void f(); //If i define function here itself, error is not reported.
};
template <class T>
void Test<T>::f()
{
} //Error here.
int main()
{
Test<float> ob;
ob.f<int>();
}
It produces below error.
error C2244: 'Test<T>::f' : unable to match function definition to an existing declaration
definition 'void Test::f(void)'
existing declarations 'void Test::f(void)'
Error says declaration and definitions have the same prototype but not matching. Why is this an error ? and how to solve it ?
If i define function within the class, it doesn't report error. But i want to define outside the class.