This code doesn't work.
class Collidable{
public:
virtual Vec2 Pos()=0;
};
class Square{
Vec2 pos;
public:
Vec2 Pos(){
return pos;
}
};
class Box:public Square,public virtual Collidable{
};
main(){
Box bla;
cout<<bla.Pos()<<endl;
}
but if I do this it works.
class Box:public Square,public virtual Collidable{
public:
Vec2 Pos(){
return Square::Pos();
}
}
My problem is I have a class like Square and I have lots of functions like Pos(), and I really feel like I shouldn't have to state something like this
Vec2 Pos(){
return Square::Pos();
}
for every single function over and over again when this is what I would have thought would be the default behavior when inheriting from another class. How can I avoid a lot of redudant typing here, and what's so ambiguous about calling Pos(), when there's only one definition for it?