关于继承,子窗口上的继承于父窗口的窗口函数里面添加代码之后就只执行新添加的代码了,为什么不是先执行父窗口的窗口函数然后执行子窗口

every_one 2003-10-20 11:43:05
对于事件就可以,为什么对窗口函数就不行了?

目前我使用的方法是在自窗口的每个窗口函数里面都加上一行语句:
Super::父窗口的窗口函数名(变量名1,变量名2...)
新添加代码


请问有没有什么其它的好办法?
窗口函数能不能像事件那样处理呀?多方便。

谢谢
...全文
109 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
LeoKing 2003-10-21
  • 打赏
  • 举报
回复
函数作为最基础单元,不同于事件等;要应用则直接引用即可,而在原函数基础上进行修改,只能导致函数的重载。
若要对其进行功能性的扩充,通常方式是引用、扩展;
若预先考虑到后期的扩充性较大,则设计时一般预定义可扩充接口方式。
zzutligang 2003-10-21
  • 打赏
  • 举报
回复
那是在事件过程中,在函数过程中没有这个的。如果你可以强制调用
supper::function_name()
heartarrow 2003-10-21
  • 打赏
  • 举报
回复
我怎么记得一般情况下都是先执行父窗口的代码呢,是不是点击了"Extend Ancester Script"
every_one 2003-10-20
  • 打赏
  • 举报
回复
还有其它高见吗?
coolroy2000 2003-10-20
  • 打赏
  • 举报
回复
Finding functions:

When calling a function, PowerBuilder searches until it finds a matching function and executes it--the search ends.
Using functions with the same name but different arguments is called function overloading.
If you don't qualify a function name with an object, PowerBuilder searches for the function and executes the first one it finds that matches the name and arguments. It searches for a match in the following order:

1 A global external function
2 A global function
3 An object function and local external function (if the object is a descendant, PowerBuilder searches upward through the ancestor hierarchy to find a match for the function prototype)
4 A system function
so,你的显然不是重载的情况,按照pb处理函数和事件机制的不同而定,达到你的要求,要么copy代码,要么Super::function(当然这个简单些咯)。
zhangning163 2003-10-20
  • 打赏
  • 举报
回复
在PB中函数特征为多态性;继承只能在控件的相关属性中实现,如可视形态、事件等!
jdsnhan 2003-10-20
  • 打赏
  • 举报
回复
主要是因为实现函数重载.
qqjj7758 2003-10-20
  • 打赏
  • 举报
回复
赞成楼上的看法
workhand 2003-10-20
  • 打赏
  • 举报
回复
pb的继承就是这样。同意楼上
qiyousyc 2003-10-20
  • 打赏
  • 举报
回复
1、肯定是这样的。因为这样才可以实现函数重栽。
2、如果你要实现先执行父窗口的窗口函数然后执行子窗口里面添加的代码,那么最好用事件。
klbt 2003-10-20
  • 打赏
  • 举报
回复
个人观点:为了便于实现多态。

1,072

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧