TInstanceOf<>

A TInstanceOf save pointer points to and owns a single object. If the pointer is copied, a clone of the object is created. For example, in the following code:

    TInstanceOf<TA> a1 = new TA;
    TInstanceOf<TA> a2 = a1; // Clone happens here.
Now a2 and a1 point to different objects.

If the pointer is destroyed, it destroys the object (if any) to which it points. The template can only be expanded on a class whose destructor is public, and which is copyable; that is, Copy(AType& object) must return a pointer to a copy of the given object.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker