Thread View: gnu.g++.help
1 messages
1 total messages
Started by sherif el kassas
Fri, 21 Jun 1991 14:38
g++ (1.37.1) MI problem
Author: sherif el kassas
Date: Fri, 21 Jun 1991 14:38
Date: Fri, 21 Jun 1991 14:38
64 lines
1941 bytes
1941 bytes
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 <stream.h>
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. /
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads