Encapsulation is a technique of linking together attributes and procedures to form an object. The only way to access attributes and procedures of an object is to create an instance of the object.
As you ll recall from Chapter 2, you create an object within a program by defining a class. The class definition contains the definitions of attributes and procedures (functions in C++ and methods in Java).
Figure 3-1 shows a diagram of a class that defines the object Student. The top of the diagram is the list of attributes that describe a student. These are a student s ID, student name , and whether or not the student graduated . The bottom of the diagram is a list of procedures associated with a student. These write and display information about a student. The attributes and procedures described in Figure 3-1 are said to be encapsulated in the Student class.