我正在尝试覆盖/重载已在基类中被覆盖的虚函数。为了更好地理解我想要做什么,请查看以下示例:
public class Parent
{
public virtual void foo() {
print("Parent::foo()");
}
}
public class Derived : Parent
{
public override void foo() {
print("Derived::foo()");
}
}
public class Child : Derived
{
public override void foo() {
print("Child::foo()");
}
}
// When I create an instance of Child and call the method foo,
// it calls the Derived::foo() method and not Child::foo()
// How can I make Child override Derived::foo()?
是否可以覆盖 Derived::foo()?如果不是,你会建议我如何解决这个问题?