This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11570] incorrect behaviour in calling base class methods


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]