Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ multiple inheritance function merging

I have:

class XILightSource 
{
public:
    virtual XVec2 position() const = 0;
};

class XLightSprite : public XSprite, public XILightSource
{

};

The problem is that XSprite already has the same function position. How can i say to compiler, that i want to use XSprite::position function as an implementation of XILightSource::position() ?

like image 700
Andrew Avatar asked Oct 07 '11 05:10

Andrew


1 Answers

override it and call XILightSource::position() :

class XLightSprite : public XSprite, public XILightSource
{
  public:
     XVec2 position() const { return  XSprite::position(); }
};
like image 94
onof Avatar answered Oct 05 '22 11:10

onof