| description | Learn more about: Creating an Aggregated Object | ||
|---|---|---|---|
| title | Creating an Aggregated Object | ||
| ms.date | 11/04/2016 | ||
| helpviewer_keywords |
|
||
| ms.assetid | fc29d7aa-fd53-4276-9c2f-37379f71b179 |
Aggregation delegates IUnknown calls, providing a pointer to the outer object's IUnknown to the inner object.
-
Add an
IUnknownpointer to your class object and initialize it to NULL in the constructor. -
Override FinalConstruct to create the aggregate.
-
Use the
IUnknownpointer, defined in Step 1, as the second parameter for the COM_INTERFACE_ENTRY_AGGREGATE macros. -
Override FinalRelease to release the
IUnknownpointer.
Note
If you use and release an interface from the aggregated object during FinalConstruct, you should add the DECLARE_PROTECT_FINAL_CONSTRUCT macro to the definition of your class object.