How to Inherit method but with different return type?

前端 未结 10 1093
北荒
北荒 2021-01-17 19:20

Given the following classes:

ClassA
{
     public ClassA DoSomethingAndReturnNewObject()
     {}    
}

ClassB : ClassA
{}

ClassC : ClassA
{}
10条回答
  •  猫巷女王i
    2021-01-17 19:38

    I think that you need to create a new function with the new return type and call inside the other function, and manipulate the type returned. otherwise it will no be logical ! (with the definition/idea of inheritance)

提交回复
热议问题