Ownership of reference counting objects

A reference counting object, a CObject type, may be owned by another. This, in turn, may be owned by yet another.

Ownership simply reflects a natural relationship. For example, a timer is owned by a thread and a thread is owned by a process. These objects are all instances of classes derived from CObject.

A reference counting object assigns ownership of itself to another reference counting object using CObject::SetOwner(). For example:


...
class CMyobject : public CObject
    {
    ...
    };
class CTheOwner : public CObject
    {
    ...
    }
...
CMyobject*    owned;
CTheOwner*    owner;
...
owned->SetOwner(owner);