hello,
i have a question about Interfaces in COM
i have a Ibase interface which has a method DoBase().
i derive two classes from this base interface class CBase called
CDrived_1:CBase
CDrived_2 CBase
both class overrides Dobase Method.
CDrived_1:obase
{
__super:obase()
}
CDrived_2:obase
{
__super:obase()
}
i have a COM method which returns the Ibase Interface.
HRESULT GetInterface ( id, IBASE** pp)
{
if ( id == 0)
{
hr = CDrived_1::CreateInstance(pp);
}
if (id == 0)
{
hr = CDrived_2::CreateInstance(pp);
}
}
now in the client application if i call
IBase* pp = NUL
GetInterface (id , &pp);
pp->Dobase() //which function should be called??
i was expecting that either CDrived_1:obase() or CDrived_2:
obase() should be called. since function is virtual.
but it is calling CBase:obase()/// Why?
how should i do it so that derived one gets called.
Regards
deepak




obase
Reply With Quote