previous page
next page

VARIANTs, SAFEARRAYs, and Interface Pointers

COM has a number of data types beyond the numeric types available in the C and C++ languages. Three such data types are the VARIANT data type, interface pointers, and the SAFEARRAY data type. ATL provides useful classes that encapsulate each of these data types and their special idiosyncrasies.

The CComVariant class is a smart VARIANT class. The class implements the special initialization, copy, and destruction semantics of the COM VARIANT data type. CComVariant instances can be used in most, but not all, of the places you would use a VARIANT.

The CComPtr, CComQIPtr, and CComGITPtr classes are smart pointer classes. Smart pointer classes are definitions of objects that "act" like a pointerspecifically, a pointer with extra semantics. The major additional semantic for the ATL smart pointer classes is automatic reference counting, which eliminates entire classes of errors.

The CComSafeArray class manages the Automation array type SAFEARRAY. These arrays require special handling with dedicated API functions for allocating, deallocating, and interrogating members of the array.


previous page
next page
Converted from CHM to HTML with chm2web Pro 2.75 (unicode)