cflanman
May 17th, 1999, 11:16 AM
Business class A1 inherits from business class A, which is exposed through custom interface IA. Using ATL, how can custom interface IA1 be generated, inheriting from IA and exposing A1?
|
Click to See Complete Forum and Search --> : Implmenting Custom-Interface Inheritance cflanman May 17th, 1999, 11:16 AM Business class A1 inherits from business class A, which is exposed through custom interface IA. Using ATL, how can custom interface IA1 be generated, inheriting from IA and exposing A1? RajM May 18th, 1999, 06:19 PM Hi, Inheritance is implimented as aggregation in COM.But its not really like C++ inheritance. In C++ u can create an object of the derived class and call methods in the base class ad derived class with the same pointer.But in COM the derived COMobject aggregates the base COM object and gives access to it through a QueryInterface call e.g In C++ class Base { BaseMethod(); }; class Dervived :public Base { DerivedMethod(); }; Derived D; D.BaseMethod(); In COM: IDerivedObject *pDerivedObj; IDerivedObject *pBaseObj; Create derived object and get pointer to it Ask derived object for the base interface pointer call methods in base interface pointer. i took the folowing from MSDN Creating an Aggregate To create an aggregate 1.Add an IUnknown pointer to your class object and initialize it to NULL in the constructor. 2.Override FinalConstruct to create the aggregate. HRESULT FinalConstruct( ) { return CoCreateInstance(CLSID_SomeServer, GetControllingUnknown(), CLSCTX_ALL, IID_ISomeServer, &m_pSomeServer); } 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. 5.declare macro DECLARE_GET_CONTROLLING_UNKNOWN( ) codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |