< Previous | Contents | Next >
Like functions, you should treat objects as encapsulated entities. This means that, in general, you should avoid directly altering or accessing an object’s data members. Instead, you should call an object’s 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.