djakman@fwi.uva.nl (Kemal Djakman (I89)) (01/28/91)
// Could someone help me here?
// This is supposed to be a simple appl. of the 'virtual' inheritance in C++
// Expected result is a: A A But the result I got is a: A A
// b: B A b: A A
//
// (Only when compiled with Borland's Turbo C++ v1.0 - official patch level 1)
#include <stdio.h>
class A {
public:
virtual char f() { return 'A'; }
char g() { return 'A'; }
char testF() { return f(); }
char testG() { return g(); }
};
class B : public A {
public:
char f() { return 'B'; }
char g() { return 'B'; }
};
int main() {
A a; B b;
printf("a: %c %c\n", a.testF(), a.testG());
printf("b: %c %c\n", b.testF(), b.testG());
return 0;
}
// end of virtual inheritance test program
--
----- Kemal Djakman -----