You are creating a COM component. Other components may attempt to include this component by using aggregation. Therefore, the component that you are creating must support aggregation. Which action or actions must you design into the component? (Choose all that apply)  
 Multi Selection 
A  Implement external and internal versions of the IUnknown interface.  B  Cache a pointer to the enclosing COM component’s IUnknown interface.  C  Call the AddRef method on the enclosing COM component at activation.  D  Call the Release method on the enclosing COM component when its reference count falls to zero. 
 
E  Forward calls to the QueryInterface method to the enclosing COM component.  F  Return the value CLASS_E_NOAGGREGATION from the call the QueryInterface.  

解决方案 »

  1.   

    我只知道A,B要选,F不要选,C D E就不知道了,因为看不太明白
      

  2.   

    选A, 后面几个都是外部组件要做的事情。
    要做一个可聚合组件,只需要做两件事,第一是实现两套IUnknown接口(A),另外再用一个成员变量纪录UnknownOuter就可以了。
      

  3.   

    C与D千万不可选,只需要外部对象调用内部对象的AddRef,如果内部对象也调用外部对象的AddRef的话,会让两个组件引用循环,大家都无法注销。
      

  4.   

    它好像是问可被聚合组件的实现方式吧。除了A以外,别的都是外部组件的工作,比如说,Cache a pointer to the enclosing COM component’s IUnknown interface,内部组件Cache a pointer to the enclosing COM component’s IUnknown interface,Cache自己的指针,有什么意义?
      

  5.   

    enclosing COM component: 外部的(主动式)
    enclosed COM component:内部的
      

  6.   

    感谢paul2002()!唉~我怎么没想到英语语法的问题呢.
    可被聚合的对象A中external IUnknown interface的定义如下:
    HRESULT CA::QueryInterface(....)
    {
    if (m_pUnknownOut != NULL)
    //Answer B and E is here!!!
         return m_pUnknownOut->QueryInterface(...);
    else 
         return NodelegatingQueryInterface(..);//internal IUnknown
    }