Re: Multiple inheritance virtual abstract method disambiguation
On 2011-08-07 21:08, xKubo@hotmail.com wrote:
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++ ?
Yes. Like every other (except the halting) problem, this one can be
solved using an extra level of indirection.
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() {}
};
struct XITest1 : ITest
{
virtual void Close() { Close1(); }
virtual void Close1() = 0;
};
struct XIText2 : ITest2
{
virtual void Close() { Close2(); }
virtual void Close2() = 0;
};
struct X : XITest1, XITest2
{
virtual void Close1();
virtual void Close2();
}
--
Gerhard Menzl
Non-spammers may respond to my email address, which is composed of my
full name, separated by a dot, followed by at, followed by "sabre",
followed by a dot, followed by "com".
X-No-Acknoledgement: yes
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]