
Sometimes I like to play around with obscure code, just to see what it does. The following really surprised me: #include <iostream> struct A { public: bool operator == ( const A & rhs ) { std::cout << "A\n"; return true; } }; struct B { public: bool operator == ( const B & rhs ) { std::cout << "B\n"; return false; } }; struct C : public A, public B { }; int main ( ) { C c1, c2; if ( c1 == c2 ) std::cout << "Equal\n"; return 0; } Compiled on MSVC 7.1, this outputs: A Equal I would have expected this code not to compile at all, because the == overload seems ambiguous. Is this result standards conforming? If not, what would the standards conforming result be? Does this fall into the realm of undefined behavior? -Jason