A C++ user will say that the parameters of "get" methods of "Object" properties are pointers to an object's interface pointer. As objects' interfaces are derived from IUnknown, they may be passed as IUnknown pointers so that objects of several types may be used as input or output parameters of a property or a method (you may, however, get the interface you need by calling the QueryInterface method).
There are two different types of "put" methods for object properties - clear put, described by propput keyword in the type library (the object is copied in this case); and put by reference, described by the propputref keyword in the type library (only a pointer to an existing object's interface is stored in the property in this case). A property may support only one of these put methods; most of the Open API object properties support clear put. In Visual Basic, put by reference is performed using the Set statement, while clear put is performed without this keyword.
Suppose again the MyObject object supports MyObjectProperty property that refers to an object of MyChildObject type.
interface IMyObject : IUnknown {
...
[propget]
HRESULT MyObjectProperty([out, retval]IMyChildObject** pVal);
[propputref]
HRESULT MyObjectProperty([in]IMyChildObject* newVal);
...
};
The same property is accessed as follows in Visual Basic:
Dim ChildObj As MyChildObject
Set ChildObj=MyObject.MyObjectProperty
' Do something with the object
...
' Clear put (If it were put by reference, we would write
' Set MyObject.MyObjectProperty=ChildObj)
MyObject.MyObjectProperty=ChildObj
A C++ user writes this code in other way:
IMyObject* pMyObject;
...
IMyChildObject* pChildObj=0;
// get_ method may return 0 in certain cases
pMyObject->get_MyObjectProperty(&pChildObj);
// Do something with the object
...
pMyObject->put_MyObjectProperty(pChildObj);
...
pChildObj->Release();
Note that in C++ you should call the Release method for an object got via a property. The Native COM support calls AddRef and Release methods automatically using auto pointers. If an object property refers to a child object of the object that exposes this property, a pointer to the child object's interface is valid until its parent object exists. An attempt to access a child object after its parent object has been destroyed may results in error.