I have simple class,
class Func
{
public:
Func()
{
cout<<"Constructor"<<endl;
}
int operator()(int)
{
cout<<"Operator ()";
return 0;
}
};
- When I create it's object by giving parenthesis,
Func f();
, it prints nothing, it should print Constructor. But when I create object without parenthesis it prints Constructor which is expected. What is the different between these two? - When I try to use operator()
f(2)
it gives me compilation error.
error C2660: 'f' : function does not take 1 arguments
Isn't it strange behaviour or I am missing something?