Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
In Inner::Initialize(), which QueryInterface() and saves the interface pointer once and for all, and Release() the extra count.
If the reference count of the outer object is 0 when FinalConstruct is entered Inner::Initialize() will increment the outer object reference count to 1 and then Release() will decrement the count to 0. Inside the outer object's Release() the reference count of 0 will trigger object deletion (i.e., delete this).
ATL's implementation of stabilization will increment the outer object reference count from 0 to 1 before the call to Inner::Initialize(). So Inner::Initialize() will then increment the outer object reference count to 2 and then outer object's Release() decrements it back to 1 and so avoids object destruction.