Ralph's excellent answer. I think it's worth mentioning that providing free functions with the same name but with different types of arguments, we allow ourselves to express our intention at a high level, while free functions act like adapters. We allow ADL to find the right overload (or specialization) function for us.
Thus, we do not need to know the names of member functions in order to express logic. In this example, this will make the C class more suitable for modification and evolution later:
#include <iostream>
source share