Is COM interface support method override?
for example
interface ITest : IDispatch
AddParameter(float fA);
AddParameter(bool bA);
The wizard donot support this, Is that can implement some way?
interface ITest : IDispatch
AddParameter(float fA);
AddParameter(bool bA);
The wizard donot support this, Is that can implement some way?
COM does not support method overloading.
In your case you could make the first parameter a VARIANT so you can investigate the type of the param at runtime. In your C++ implementation you might then use method overloading, e.g.:
interface ITest : IDispatch class YourTestImpl : ITest HRESULT AddParameter(VARIANT Param) case VT_R4: // float default: return S_OK;
{
HRESULT AddParameter([in] VARIANT Param);
};
{
void addParam(bool);
void addParam(float);
{
switch(Param.vt)
{
case VT_BOOL:
addParam(Param.boolVal != VARIANT_FALSE);
break;
addParam(Param.fltVal);
break;
return E_INVALIDARG;
}
}
};
SvenC
Can you pls explain the technical reason behind COM prohibiting Interface method overload? Thank you very much.
I am just guessing here: COM should be useable from different languages and not all of them support overloding. Most important VB <= version 6, which I would name the most prominent language with COM support.
--
SvenC