如何在重写方法中表示调用基类方法? [英] How to represent calling base class method in overridden method?

查看:57
本文介绍了如何在重写方法中表示调用基类方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个子类想要向基类函数添加更多功能,我怎么能表示它也执行基类函数而不仅仅是新添加的功能?

I have a child class which wants to add more functionality to a base class function, how can I represent that it also does the base class function not just the newly added functionality?

推荐答案

有趣的问题.我用 Enterprise Architect 试过了.它确实让我选择了父级的操作,但图中的显示没有改变.看来您需要为此使用注释:

Interesting question. I tried that with Enterprise Architect. It did let me select the parent's operation but the display in the diagram did not change. It seems like you need to use notes for that:

如您所见,Class2 继承自 Class1.SD 显示了对Class2 操作a() 的调用.对超类的 Class1.a() 作为内部调用的调用显示了相同的签名.注释说明了情况.

As you can see Class2 inherits from Class1. The SD shows a call to Class2's operation a(). The call to the super-class's Class1.a() as internal call shows the same signature. A note clarifies the situation.

也许这还有其他可能.但这就是我立即想到的.

Maybe there's something else possible with this. But that's what I came up with immediately.

附言我查了一下规格.UML 2.5 的第 575 页说

P.S. I've looked up the specs. P. 575 of UML 2.5 says

出现在请求消息标签中的消息名称是消息的名称属性.如果消息有签名,这将是签名引用的操作或信号的名称.否则名称不受约束.

The message-name appearing in a request-message-label is the name property of the Message. If the Message has a signature, this will be the name of the Operation or Signal referenced by the signature. Otherwise the name is unconstrained.

这将放入将相关操作指定为 Class1:a() 等的选项.实际上 Enterprise Architect 在消息的属性中以这种方式显示它,但将其缩短为基本名称.我猜这只是一个边界案例.

That would put in the option to specify the operation in question as Class1:a() or the like. Actually Enterprise Architect shows it that way in the properties of the message but shortens it to just the basic name. Just a border case, I'd guess.

这篇关于如何在重写方法中表示调用基类方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆