Force invocation of base class method

后端 未结 6 435
庸人自扰
庸人自扰 2020-12-11 23:53

The following code when run obviously prints out \"B1/A2/B2\". Now, is it possible for it to print \"A1/A2/B2\" instead (i.e. A#method2() should invoke method1() on A, not

6条回答
  •  庸人自扰
    2020-12-12 00:49

    You could also make the A.method1 private. Then, even if you have B.method1, A.method1 will be called instead. But I'm not sure about that, you should check

提交回复
热议问题