Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!spool2.mu.edu!uunet!mcsun!hp4nl!fwi.uva.nl!gene!djakman From: djakman@fwi.uva.nl (Kemal Djakman (I89)) Newsgroups: comp.lang.c++ Subject: Help with TC++ Summary: Problem with virtual mechanism in Borland's TC++ 1.0 Keywords: virtual inheritance Message-ID: <1991Jan28.135227.1735@fwi.uva.nl> Date: 28 Jan 91 13:52:27 GMT Organization: FWI, University of Amsterdam Lines: 38 // 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 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 -----