newObjects-logo.gif (1024 bytes) ScriptManager2 reference

Assignment operators

Operators calling AddRef of the assigned pointer.

These operators call AddRef method of the interface pointer being packed in the object.

DISPCALLER& DISPCALLER::operator =(
IDispatch* pDisp // Replace packed dispatch. AddRef of the new interface pointer is called.
);
DISPCALLER& DISPCALLER::operator =(
IUnknown* pUnk // Replace packed dispatch by obtaining new through QueryInterface of the passed IUnknown*.
);

Operators that do not call AddRef

DISPCALLER& DISPCALLER::operator <=(
IDispatch* pDisp // Replace packed dispatch. AddRef of the new interface pointer is NOT called.
);

Interface pointer (if any) hold by the object before operator usage is released automatically.

 

Remarks:

These operators are provided in order to be used in different situations. = operator(s) are for the case when "new copy" of the interface pointer is needed and <= operator(s) are for the case when the caller has a pointer with AddRef called and wants to delegate life-time control to a DISPCALLER object.

<= is most useful to init the object from the return value of functions returning interface pointer with previously called AddRef. At the other hand operator = is most useful to obtain "copy" of the interface pointer from another independently controlled pointer variable or object implementing smart pointer behavior.

newObjects Copyright newObjects 2001-2005