Re: Multiple inheritance virtual abstract method disambiguation
On Aug 8, 8:03 pm, Johannes Schaub <schaub.johan...@googlemail.com>
wrote:
xK...@hotmail.com wrote:
Hi,
Assume the ITest and ITest2 cannot be modified, and I would like to
implement them in one class, but differently for each interface, is it
possible in standard C++ ?
struct ITest
{
virtual void Close() = 0;
};
struct ITest2
{
virtual void Close() = 0;
};
struct X : ITest, ITest2
{
///// something like this is probably incorrect
//// virtual void ITest::Close() {}
//// virtual void ITest2::Close() {}
};
Herb Sutter wrote on this. It's described athttp://www.gotw.ca/gotw/039.htm
In a nutshell, introduce MyITest1 and MyITest2 that derives from ITest and
ITest2 respectively. Implement the respective Close function by calling a
differently-named virtual function Close1 and Close2 respectively. Then
derive X from MyITest1 and MyITest2 and implement Close1 and Close2.
As long as the ancestor's methods are abstract the commented
implementation works in Visual studio 2010.
So, I was curious if something similar exists in standard C++ ( except
the trivial solution involving more classes).
It doesn't seem to exist.
Anyway, thank you for your answer.
xKubo
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]