Tools.h++ Manual

12-6 104011 Tandem Computers Incorporated
12
12.2 Retrieving objects
Properties of objects
Every object that you create has three properties associated with it:
1. Its "type" ( e.g., a
RWCString
or a "double"). In C++, an object's type is set
at creation. It cannot change.
2. Its "state" ( i.e., the value of the string). The values of all the instance
variables or attributes of an object determine its state. These can change.
3. Its "identity" (i.e., identifies an object uniquely and for all time). In C++, an
object's identity is determined by its address. Each object is associated with
one and only one address. Note that the reverse is not always true because
of inheritance. Generally, an address and a type
1
is necessary to
disambiguate which object you mean within an inheritance hierarchy.
Note – Different languages use different methods for establishing an object's
identity. For example, an object-oriented data base could use an "object ID" to
identify a particular object. It is just a property of C++ that an object's address
is used.
Retrieval methods
How an object is "found" within a collection class depends on how you use
these three properties.
Note – A key point is that there are two general methods for "finding" an object
and you will have to keep in mind which you mean. Some collection classes
can support either method, some can support only one.
1. Because of multiple inheritance it may be necessary to know not only the object’s type, but also its location
within an inheritance tree inorder to disambiguate which object you mean.