This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11570] incorrect behaviour in calling base class methods
- From: "OMS-sero dot Project at ict dot nl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Jul 2003 09:40:51 -0000
- Subject: [Bug c++/11570] incorrect behaviour in calling base class methods
- References: <20030718095017.11570.OMS-sero.Project@ict.nl>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11570
------- Additional Comments From OMS-sero dot Project at ict dot nl 2003-07-24 09:40 -------
Subject: Re: incorrect behaviour in calling base class methods
Hi,
This will trigger the PR:
class Menu
{
public:
Menu(){};
virtual ~Menu(){};
virtual const bool getCurrentAction() const {return true;};
};
class MenuDevice
{
public:
MenuDevice(){};
virtual ~MenuDevice(){};
virtual const bool isPresent() const {return true;};
virtual const int getValue(int id) const = 0;
};
class MenuLeft:
public MenuDevice, // Swap this line
public Menu // with this one, and it will NOT work!!
{
public:
MenuLeft(){};
virtual ~MenuLeft(){};
const int getValue(int id) const {return 10;};
};
MenuLeft *globalMenuLeft = 0;
MenuDevice** globalMenuDevice = (MenuDevice**) &globalMenuLeft;
int main()
{
globalMenuLeft = new MenuLeft;
(*globalMenuDevice)->isPresent();
return 0;
}
With kind regards,
Marwijn