inherited何时用?含义是什么?(100分)

  • 主题发起人 主题发起人 hfxf1980
  • 开始时间 开始时间
H

hfxf1980

Unregistered / Unconfirmed
GUEST, unregistred user!
各位高手:
inherited何时用?含义是什么?
请举例说明一下!
谢谢!!!
 
继承父类相应的东东。
 
繼承
如果不懂就應該去學點語言知識
 
继承父类的方法,属性等
 
The reserved word inherited plays a special role in implementing polymorphic behavior. It can occur in method definitions, with or without an identifier after it.
If inherited is followed by the name of a member, it represents a normal method call or reference to a property or field--except that the search for the referenced member begin
s with the immediate ancestor of the enclosing method's class. For example, when
inherited Create(...);
occurs in the definition of a method, it calls the inherited Create.
When inherited has no identifier after it, it refers to the inherited method with the same name as the enclosing method or, if the enclosing method is a message handler, to the inherited message handler for the same message. In this case, inherited takes no explicit parameters, but passes to the inherited method the same parameters with which the enclosing method was called. For example,
inherited;
occurs frequently in the implementation of constructors. It calls the inherited constructor with the same parameters that were passed to the descendant.
多用F1.....帮助是最好的参考书!
 
inherited 是继承父类方法的意思。当你自定义控件或自定义类的时候,新类用父类已有的方法就需要继承。例如:MyButton 是从TButton类继承的。则写MyButton类的OnMouseDown时就需要继承。
procedure TForm1.MyButtonMouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
inherited;
你的代码。。。。
end;
 
如果寫成這樣
begin
你的代码。。。。
inherited;
end;

那就會先執行你的代碼再去執行父類的方法
 
建议参阅面向对象的技术
 
接受答案了.
 
谢谢各位
 
后退
顶部