When should i make a function private
and why is it good idea?
If you are designing a class - considering the way client code should use it - then you will inevitably derive an interface consisting of public
and perhaps protected
members.
private
members are functions and data that supports and enables those public/protected members. private
functions should factor and/or modularise/structure the code needed by the non-private
members, making their implementation less redundant and easier to understand.
Summarily, you make a member private
if it's not intended for direct use by client code, and only exists to support the non-private
members.