I used a template within a c++ class. However, when I try to call a function using a template from another function in the class, I get an error. What should I fix?
void MyClass::Display()
{
cout << "sum : ";
cout << setw(30) <<Add();
}
template <typename T>
T MyClass::Add()
{
T sum=0;
for (int i = 0; i < 15; i++)
{
sum += y[i];
}
return sum;
}
In this way, an error occurs in add() of the display part