< Previous | Contents | Next >

Setting Member Access Levels

Like functions, you should treat objects as encapsulated entities. This means that, in general, you should avoid directly altering or accessing an objects data members. Instead, you should call an objects member functions, allowing the object to maintain its own data members and ensure their integrity. Fortunately, you can enforce data member restrictions when you define a class by setting member access levels.


 

Introducing the Private Critter ProgramSpecifying Public and Private Access LevelsDefining Accessor Member FunctionsDefining Constant Member Functions