Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 1.55 KB

creating-an-aggregated-object.md

File metadata and controls

36 lines (28 loc) · 1.55 KB
title ms.custom ms.date ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
Creating an Aggregated Object | Microsoft Docs
11/04/2016
cpp-windows
article
C++
aggregation [C++], creating aggregated objects
aggregate objects [C++], creating
fc29d7aa-fd53-4276-9c2f-37379f71b179
10
mikeblome
mblome
ghogen

Creating an Aggregated Object

Aggregation delegates IUnknown calls, providing a pointer to the outer object's IUnknown to the inner object.

To create an aggregated object

  1. Add an IUnknown pointer to your class object and initialize it to NULL in the constructor.

  2. Override FinalConstruct to create the aggregate.

  3. Use the IUnknown pointer, defined in Step 1, as the second parameter for the COM_INTERFACE_ENTRY_AGGREGATE macros.

  4. Override FinalRelease to release the IUnknown pointer.

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.

See Also

Fundamentals of ATL COM Objects