// member function
x = 5;
// free function
void foo(S& s)
s.x = 5;
s.foo(); // calls the member function
foo(s); // calls the free function
These two functions named "foo" are more or less identical if we ignore the syntactical difference. The object is essentially "passed" to the member function using an implicit this parameter.
Now, what if we want to write a function "bar" that does not modify the object, and that can be used with objects declared as const?
With a free function it's easy, just mark the parameter reference as const.