D
Dwight Army of Champions
I know that no outside functions can directly acces private data
members of a class, and that all interface should be done through the
get and set accessor/mutator functions, but my question is: What are
class member functions allowed to access their own private data
members? Because of these, data members can be manipulated and changed
without use of the accessors and mutators, and couldn't such behavior
wreak havoc on programs? Why not force the class member functions to
also only use accessors and mutators? That way, if there was a
problem, then the programmer KNOWS that the issue is with the get and
set functions and not anywhere else.
members of a class, and that all interface should be done through the
get and set accessor/mutator functions, but my question is: What are
class member functions allowed to access their own private data
members? Because of these, data members can be manipulated and changed
without use of the accessors and mutators, and couldn't such behavior
wreak havoc on programs? Why not force the class member functions to
also only use accessors and mutators? That way, if there was a
problem, then the programmer KNOWS that the issue is with the get and
set functions and not anywhere else.