I'm getting the next error and I cannot find the reason for it:
Error C2664 'void SumID<long>::operator ()<int>(G &)': cannot convert argument 1 from 'int' to 'int &'
Why is passing an int by reference problematic?
I have the next class:
template <class T>
class SumID {
private:
T sumid;
public:
SumID():sumid()
{
}
SumID(T s)
{
sumid = s;
}
T getSumID()
{
cout << "inside getSum";
return sumid;
}
template <class G>
void operator() (G& a)
{
sumid = sumid+ a;
}
};
my main :
SumID<long> s;
for (int i = 0; i < 5; i++)
s(5); // <-- error here