Description

TInstanceOf(AType* adopt) -- adopts the given object. The object is not copied. So, in the code:

      TA* a1 = new TA;
      TInstanceOf<TA> a2 (a1);
there is still only one object. This can lead to erroneous aliasing, and possibly double deletion. If the given pointer is NIL, the resulting TInstanceOf does not point to any object.

TInstanceOf(const TInstanceOf& copy) -- copies the object pointed to by the given TInstanceOf (if any), and adopts the copy.

~TInstanceOf() -- destroys the object being pointed to (if any).

operator=(AType* adopt) -- adopts the given object, and destroys the object (if any) to which this wrapper pointed previously. The new object (if any) is not copied.

operator=(const TInstanceOf& rhs) -- copies the object pointed to by the given TInstanceOf (if any), adopts the copy, and destroys the object (if any) to which this wrapper pointed previously.

Orphan() -- returns a copy of the pointer, and releases the management of it. GetAlias() will subsequently return NIL.

operator ==(), operator !=() -- compare the pointers for equality. operator == returns kTrue if they point to the same object, or if they are both NIL; otherwise it returns kFalse. operator != is the Boolean negation of operator ==.

Resurrect (TInstanceOf<AType>&, TStream& from,...) -- resurrects an object from a stream, and assigns a pointer to the resurrected object into the wrapper. This function won't compile unless Resurrect(AType*&, TStream&) is available.

TInstanceOf also inherits the interface and implementation of TPointerTo.

    
    


[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