Partager via


DECLARE_POLY_AGGREGATABLE

Specifies that an instance of CComPolyObject < x > is created when your object is created.

DECLARE_POLY_AGGREGATABLE( 
      x  
)

Parameters

  • x
    [in] The name of the class object you are defining as aggregatable or not aggregatable.

Remarks

During creation, the value of the outer unknown is checked. If it is NULL, IUnknown is implemented for a nonaggregated object. If the outer unknown is not NULL, IUnknown is implemented for an aggregated object.

The advantage of using DECLARE_POLY_AGGREGATABLE is that you avoid having both CComAggObject and CComObject in your module to handle the aggregated and nonaggregated cases. A single CComPolyObject object handles both cases. This means only one copy of the vtable and one copy of the functions exist in your module. If your vtable is large, this can substantially decrease your module size. However, if your vtable is small, using CComPolyObject can result in a slightly larger module size because it is not optimized for an aggregated or nonaggregated object, as are CComAggObject and CComObject.

The DECLARE_POLY_AGGREGATABLE macro is automatically declared in your object if you use the ATL Control Wizard to create a full control.

Requirements

Header: atlcom.h

See Also

Concepts

Aggregation and Class Factory Macros

ATL Macros

CComPolyObject Class

CComAggObject Class

CComObject Class