get拿到原始指针,然后再进行强制类型转换

解决方案 »

  1.   

    CComPtr<IABC>Test;
    ...
    Test->get();
    没有“get” 这个成员呀。
      

  2.   

    COM的智能指针转换必须要要有接口支持,通过QueryInterface获取接口
    CComPtr重载了=运算,如果有接口支持,可以直接使用等号转换 template <typename Q>
    T* operator=(_In_ const CComPtr<Q>& lp) throw()
    {
            if( !IsEqualObject(lp) )
            {
         return static_cast<T*>(AtlComQIPtrAssign((IUnknown**)&p, lp, __uuidof(T)));
            }
            return *this;
    }