0
struct IA
{
virtual void Init() = 0;
.....
};
struct A : public IA
{
void Init() {};
.....
};
struct B : public A
{
int Init() { return 1; };
};
有了这样的设计,我得到错误C2555:“B ::初始化”:重写虚函数返回类型...隐瞒在派生类接口基类的特定功能
我能以某种方式掩盖初始化()来自A,我不想隐瞒其他A的功能。 A级不仅通过B级而从其他地方用作A级。
编辑:我需要在层次结构中有两个初始函数,只有返回类型不同。 我不需要A :: Init来调用B类型的对象。 其实我可以通过
struct B : private A
{
using A::.... // all, except Init
int Init() { return 1; };
};
做,但在一:(
你不完全清楚你想完成什么。 – Brian
也许你的'Init'函数不应该是虚拟的。 – Brian
@布赖恩比,你可以把它作为答案,并将它。但是,现在它对我来说很有趣,至于乐趣。所以,任何其他答案表示赞赏。 – Yola