We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.


Indicates that the class supports aggregation.

[ aggregatable(  
) ]

value (optional)

A parameter to indicate when the COM object can be aggregated:

  • never   The COM object cannot be aggregated.

  • allowed   The COM object can be created directly or it can be aggregated. This is the default.

  • always   The COM object cannot be created directly and can only be aggregated. When you call CoCreateInstance for this object, you must specify the aggregating object's IUnknown interface (the controlling IUnknown).

The aggregatable C++ attribute has the same functionality as the aggregatable MIDL attribute. This means that the compiler will pass the aggregatable attribute through to the generated .idl file.

This attribute requires that the coclass, progid, or vi_progid attribute (or another attribute that implies one of these) also be applied to the same element. If any single attribute is used, the other two are automatically applied. For example, if progid is applied, vi_progid and coclass are also applied.

ATL Projects

If this attribute is used within a project that uses ATL, the behavior of the attribute changes. In addition to the previously described behavior, the attribute also adds one of the following macros to the target class:

// cpp_attr_ref_aggregatable.cpp
// compile with: /LD
#include "atlbase.h"
#include "atlcom.h"


[ coclass, aggregatable(allowed),
class CMyClass {};

Attribute Context

Applies to

class, struct



Required attributes

One or more of the following: coclass, progid, or vi_progid.

Invalid attributes


For more information about the attribute contexts, see Attribute Contexts.