Free function versus member function
问题 What is the advantage of having a free function (in anonymous namespace and accessible only in a single source file) and sending all variables as parameters as opposed to having a private class member function free of any parameters and accessing member variables directly? Thanks! header: Class A { int myVariable; void DoSomething() { myVariable = 1; } }; source: namespace { void DoSomething2(int &a) { a = 1; } } int A::SomeFunction() { DoSomething2(myVariable); // calling free function