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