Home Segments Top Top Previous Next

164: Mainline

Once you have defined a class, you can create any number of class instances that belong to that class, each of which corresponds to an individual that belongs to the corresponding category.

When you define the Movie class, for example, you indicate that all movies are associated with numbers that express the quality of the script, the acting, and the direction. Then, you can construct movie instances with particular numbers for the script, the acting, and the direction. Thus, the employment of classes enables you to create information bundles in your programs that describe naturally occurring individuals. The class acts as a factory for class-instance production:

                 Instances 
                   | 
                   v 
*---------*      ---------------------------------------------- 
|         |      *----*  *----*  *----*  *----*  *----*  *----* 
| A Class | ---> |    |  |    |  |    |  |    |  |    |  |    | 
|         |      *----*  *----*  *----*  *----*  *----*  *----* 
*---------*