What is the meaning of the line int operator ()(int n) ?
It looks like a function but what is it?
class collatzer
{
private:
int counter = 0;
public:
int operator ()(int n)
{
if(n==1)
return counter;
else if(n%2==0) //if n is even
{
counter += 1;
return (*this)(n / 2);
}
else
{
counter += 1;
return (*this)(3 * n + 1);
}
}
int getCounter()
{
return counter;
}
};