1 2 3 4 5 6 7 8 9

It is common (and not necessarily bad) for classes to have
many data members and member functions. Here we will
focus on a few elegant problems that are amenable to tidy
hierarchies. Thus we will have to worry about access
control--which members (function or data) are visible to
which other parts of the software. This is critical, because
it directly affects data hiding.


Access Control


Three levels:


public:
Accessible to everyone from everywhere


private (default):
Accessible only by member functions


protected:
A hybrid. Treated as private, except also visible to
friendfunctions, and those functions from derived
classes.


A friend function is a function listed in the class declaration
as a friend. In the C++ world, at least, friends give access
to the private parts...


For the moment we will set-aside derived classes (though
they are the heart of code sharing in C++ and so cannot be
omitted).

8 March, 1998

Page {PAGE }

TAM/DS