The pointer classes the #import directive generates automatically add object references when you construct a pointer, as shown in the following code:

TS::PropertyObjectPtr newObjectPtr(objectPtr);

The assignment operator of the pointer classes first releases the reference to the object it currently holds and then adds a reference to the object being assigned to it. For example, the following assignment statement first releases the reference to the object to which newObjectPtr refers and then adds a reference to the object to which objectPtr refers:

newObjectPtr = objectPtr;

The destructor for the pointer class releases the object reference. Assigning the value NULL to a pointer variable also releases the object reference, as shown in the following example:

objectPtr = NULL; // releases the reference