[Solved] Why strange behaviour with operator()? [duplicate]


Func f();, it prints nothing, it should print Constructor

That is not true whatsoever.

Here is how you create a Func:

Func f;

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?

Yes, it’s strange, but it’s not unexpected. When you wrote Func f() you declared a function called f returning a Func. Everything you try to do with f after that is, naturally, broken.

5

solved Why strange behaviour with operator()? [duplicate]