|
-
May 17th, 1999, 11:16 AM
#1
Implmenting Custom-Interface Inheritance
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?
-
May 18th, 1999, 06:19 PM
#2
Its done through aggregation but its not as same as C++ inheritance
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 ublic 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( )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|