如何从子类的方法访问超类的方法?访问超类的成员函数
这里是一个能说明问题的例子: 比方说,我们有两个班
class parent definition.
public section.
methods f.
endclass.
class child definition inheriting from parent.
public section.
methods f redefinition.
methods g.
endclass.
现在,在g
实现中,我们要调用超类的实现的f
相似以下语法错误的片段
class child implementation.
method g.
super->f(). "forbidden: super-> can only be used to call the previous implementation of the same method
endmethod.
endclass.
正如评论指出,这是不可能使用super->
。你能帮我吗?
一些google搜索后,有人建议的parent->f
执行复制到child->g
这是真的做到这一点的唯一途径?
实际使用情况
@vwegert问为什么f
首先被重新定义。在我的真实使用案例中,parent
是一个视图,而child
是它的扩展。 child->f
是一个应该触发弹出窗口的事件处理程序。 child
当弹出窗口以g
的呼叫形式关闭时收到回叫。如果调用g
,则应调用原始实现parent->f
。
为什么你首先重新定义方法......? – vwegert
@vwegert我已经将实际用例添加到问题中,但我相信,一般问题也应该得到答案。 – niklasfi