< previous page page_847 next page >

Page 847
0847-01.gif
Figure 15-3
Conceptual View of Two Class Objects
trol exits its surrounding block) or static (created once when control reaches its declaration and destroyed when the program terminates).
In other ways, C++ treats structs and classes differently from built-in types. Most of the built-in operations do not apply to structs or classes. You cannot use the + operator to add two TimeType objects, nor can you use the == operator to compare two TimeType objects for equality.
Two built-in operations that are valid for struct and class objects are member selection (.) and assignment (=). As with structs, you select an individual member of a class by writing the name of the class object, then a dot, then the member name. The statement
time1.Increment();
invokes the Increment function for the time1 object, presumably to add one second to the time stored in time1. The other built-in operation, assignment, performs aggregate assignment of one class object to another with the following semantics: If x and y are objects of the same class, then the assignment x = y copies the data members of y into x. Below is a fragment of client code that demonstrates member selection and assignment.

 
< previous page page_847 next page >