Of course, careful coding and use of
preprocessor macros is required with C, and we could certainly get away with the
same thing in C++ if it weren’t for one problem: a macro has no concept of
the scoping required with member functions. The
preprocessor simply performs text substitution, so you
cannot say something like
or anything even close. In addition,
there would be no indication of which object you were referring to. There is
simply no way to express class scope in a macro. Without some alternative to
preprocessor macros, programmers will be tempted to make some data members
public for the sake of efficiency, thus exposing the underlying
implementation and preventing changes in that implementation, as well as
eliminating the guarding that private
provides.