What are the benefits of free functions in an unnamed namespace over a class with private member functions?

see this question: Effective C++ Item 23 Prefer non-member non-friend functions to member functions and also C++ Member Functions vs Free Functions You should prefer free functions, in the extent that it promotes loose coupling. Consider making it a member function only if it works on the guts of your class, and that you consider … Read more

Effective C++ Item 23 Prefer non-member non-friend functions to member functions

Access to the book is by no mean necessary. The issues we are dealing here are Dependency and Reuse. In a well-designed software, you try to isolate items from one another so as to reduce Dependencies, because Dependencies are a hurdle to overcome when change is necessary. In a well-designed software, you apply the DRY … Read more

Operator overloading : member function vs. non-member function?

If you define your operator overloaded function as member function, then the compiler translates expressions like s1 + s2 into s1.operator+(s2). That means, the operator overloaded member function gets invoked on the first operand. That is how member functions work! But what if the first operand is not a class? There’s a major problem if … Read more