【发布时间】:2014-05-21 05:20:34
【问题描述】:
请看下面的代码
Class A
{
method1 ()
{
code;
code;//I want to run the code at this point and then resume with the child class method
code;//dont want this code If called from derived class
}
}
Class B:A
{
method1()
{
super();// Calling method1 of class A
}
}
请建议我有多少种方法可以实现这一目标。我不想重新编写与 A 类的方法 1 中相同的代码。
【问题讨论】:
-
为什么?你的意思是“super.method1();”对吗?
-
我认为这做不到。
-
@ElliottFrisch 否则我将不得不在 B 类中重新编写 A 类代码
标签: oop inheritance code-reuse