www.digitalmars.com         C & C++   DMDScript  

c++.beta - Re: explicit override for virtual functions of several base classes

Recently I faced a problem of implemented 2 interfaces with overlapped 
function names in one derived class.
The code below was tested to compile and work properly with MSVC 8.0, 
but fails to compile with DMC.

Does C++ standard define proper way of explicit overriding of virtual 
functions, that will work for both compilers?
googling on this problme didn't help :(

#include <stdio.h>

class A {
public:
   virtual void func() = 0;
};

class B {
public:
   virtual void func() = 0;
};

class C: public A, public B {
public:
   virtual void A::func() { printf("override A\n"); }
   virtual void B::func() { printf("override B\n"); }
};

void call_a(A &a) { a.func(); }
void call_b(B &b) { b.func(); }
void call_c(C &c) { printf("print C\n"); ((A&)c).func(); ((B&)c).func(); }

int main()
{
   C c;
   call_a(c);
   call_b(c);
   call_c(c);
}
Aug 20 2009