Xref: utzoo gnu.g++.help:883 comp.lang.c++:14363 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbage From: elkassas@eb.ele.tue.nl (sherif el kassas) Newsgroups: gnu.g++.help,comp.lang.c++ Subject: g++ (1.37.1) MI problem Message-ID: <1228@eba.eb.ele.tue.nl> Date: 21 Jun 91 14:38:46 GMT Sender: daemon@tut.cis.ohio-state.edu Followup-To: gnu.g++.help Organization: Eindhoven University of Technology, The Netherlands Lines: 64 Hi all, I'm using g++ version 1.37.1 (based on GCC 1.37) on apollo systems running SR10.{2,3} Now, I've got this MI example. The class structure looks like this: B1 B2 \ / D All classes define two virtual methods called x and y. My problem is that if i call method x of a D object METHOD y IS EXECUTED. (when using a pointer to the object, see void f(D* v)) To make it more interesting, if i swap the lines labeled // 1 and // 2, the bug goes away. Am i doing something wrong, or is this a g++ MI bug ? Thanks, Sherif ----------------test.cc---------------------- #include class B1 { public: virtual void x(){ cout << "B1::x()\n"; } // 1 virtual void y(){ cout << "B1::y()\n"; } // 2 }; class B2 { public: virtual void y(){ cout << "B2::y()\n"; } virtual void x(){ cout << "B2::x()\n"; } }; class D : public B1, public B2 { public: virtual void y(){ cout << "D::y()\n"; } virtual void x(){ cout << "D::x()\n"; } }; void f(D* v) { cout << "f: v->x() "; v->x(); } main() { D d; cout << "d.x() "; d.x(); f(&d); } --------sample output----------------------------- d.x() D::x() f: v->x() D::y() Sherif El-Kassas, elkassas@eb.ele.tue.nl . :. Digital Systems Group, EH 11.29 \_____o__/ __________ Eindhoven University of Technology, .. / 5600 MB Eindhoven, The Netherlands. /