-1
我有以下的接口和類實現從其中衍生自另一個接口派生
public interface IBase
{
virtual void SomeBaseMethod()=0;
}
public interface IDerived : IBase
{
virtual void SomeOtherMethod()=0;
}
public class base: public IBase
{
void SomeBaseMethod(){};
}
public class derived: public base, public IDerived
{
void SomeBaseMethod(){};
void SomeOtherMethod(){};
}
在派生類,我必須重複的接口派生的類「無效SomeBaseMethod(){};」,它已經在我的班級實施。否則,我會得到編譯錯誤。是否可能不重複'void SomeBaseMethod(){};'在我的班級派生?
你有[鑽石繼承](https://stackoverflow.com/questions/2659116/how-does-virtual-inheritance-solve-the-diamond-multiple-inheritance-ambiguit)問題。 – CoryKramer
哪個版本的C++具有關鍵字'interface'。看起來更像Java。 –
@ThomasMatthews它不是標準的C++,但是它是[Visual Studio中的擴展](https://msdn.microsoft.com/en-us/library/737cydt1.aspx)(我不推薦使用) – CoryKramer