No, why? If you have functionality that is logically a function (stateless calculation), and there is no good reason to implement it as a class, then just implement it as a function.
The advice "replace function calls with the same name classes and call constructors of this class instead of the original function call" is incorrect: how can you replace
int y = f(x);
through class f and calling its constructor? The constructor has no return value! The only way to get this to work is to overload operator() on class f so you can use one of
int y = f(x)(); int y = f()(x);
both of them are meaningless. (In addition, you will need to remember which one you need for each function object you define.)
There must be something you donβt tell us about.
source share