我有以下情况:
class Fork {
public:
virtual void use() = 0;
};
class Spoon {
public:
virtual void use() = 0;
};
class SilverSpoon : public Spoon {
public:
virtual void use() { }
};
class SilverSpork : public SilverSpoon, public Fork {
public:
using SilverSpoon::use;
};
我希望纯虚函数Fork::use
将由SilverSpoon::use
in定义SilverSpork
。但是,我得到
error: cannot declare variable ‘spork’ to be of abstract type ‘SilverSpork’
note: because the following virtual functions are pure within ‘SilverSpork’:
note: virtual void Fork::use()
有没有办法解决这个问题而无需添加
virtual void use() {
SilverSpoon::use();
}
到SilverSpork
?