multiple inheritance confusion
Hi all,
given the following code:
#include <iostream>
struct Abstract {
virtual void HandleIt() = 0;
virtual void Handle( int ) = 0;
virtual ~Abstract() {}
};
struct A : Abstract {
virtual void HandleIt() {
std::cout << "A::Handle()" << std::endl;
Handle( 1 );
}
virtual void Handle( int ) {
std::cout << "A::Handle( int )" << std::endl;
}
};
struct B : Abstract {
virtual void HandleIt() {
std::cout << "B::Handle()" << std::endl;
Handle( 1 );
}
virtual void Handle( int ) {
std::cout << "B::Handle( int )" << std::endl;
}
};
struct C : A, B {
virtual void HandleIt() {
std::cout << "C::Handle()" << std::endl;
B::HandleIt();
}
};
int main() {
C theC;
theC.HandleIt();
}
Why doesn't theD.HandleIt() cause an ambiguity error? With the compilers
I tested (gcc 4 and Borland C++ 5.82), B::Handle( 1 ) was called. Since
this call is virtual and the dynamic type of the object is C, I expected
a compiler error, just like when typing theC.Handle( 1 );
Could someone point me to the part of the spec that talks about this - or
is this simply an implementation defined coincidence?
Thanks in advance,
Zero
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]