delphi封装了windows的消息循环,delphi的所有组件都继承自TObject类
inherited是使当前组件不处理的一些消息,向类继承层次中的上一级传递,并最终实现消息被父类默认处理。
inherited是使当前组件不处理的一些消息,向类继承层次中的上一级传递,并最终实现消息被父类默认处理。
解决方案 »
- 有什么办法可以把赋值之后的sql代码show出来?
- 关于DELPHI写的WEBSERVICE,总是使IIS挂掉的问题
- delphi 中如何从数据库中读取数据自生成TreeView,只有两个字段,数据库结构如下。急急!!
- 怎么取得数码相片的exif
- 如何导出SQL 大字段中的DOC文件
- 我不關閉ADOQuery,但是窗體關閉中寫入action:=cafree,會不會出現內存洩漏?請指教!謝謝
- 请问在那里可以下载到installshile的非限制版本
- adoquery的问题
- 请问delphi中怎样实现图像扫描并储存?
- 谁有delphi的指针文章
- 当把一列数据赋给另一列时,怎么源列的数据不见了。
- sql server6.5数据恢复的问题????100分。
没有就是没有继承罗
If inherited is followed by the name of a member, it represents a normal method call or reference to a property or field梕xcept that the search for the referenced member begins with the immediate ancestor of the enclosing method抯 class. For example, wheninherited 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. 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.
inherited的作用是调用父类的成员函数,不加函数名是调用父类中同名的方法。
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
THuman=class //基类
public
procedure showinfo1;virtual;
procedure showinfo2;virtual;
end;
TStudent=class(Thuman) //派生类
public
procedure showinfo1;override;// 虚拟继承
procedure showinfo2;override;
end;
TWorker=Class(THuman) //派生类
public
procedure showinfo1;override;
procedure showinfo2;override;
end;
var
Form1: TForm1;implementation{$R *.dfm}
procedure THuman.showinfo1 ;
begin
ShowMessage('THuman Showinfo1');
end;
procedure THuman.showinfo2 ;
begin
ShowMessage('THuman Showinfo2');
end;
procedure TStudent.showinfo1 ;
begin
ShowMessage('TStudent Showinfo1');
inherited showinfo2; //调用父类中不同名的成员函数
end;
procedure TStudent.showinfo2 ;
begin
ShowMessage('TStudent Showinfo2');
end;
procedure TWorker.showinfo1 ;
begin
ShowMessage('TWorker Showinfo1');
inherited; //调用父类中的同名函数
end;
procedure TWorker.showinfo2 ;
begin
ShowMessage('TWorker Showinfo2');
end;
procedure TForm1.Button1Click(Sender: TObject);
var
H:THuman;
begin
H:=THuman.Create ;
h.showinfo1;
h.showinfo2;
end;procedure TForm1.Button2Click(Sender: TObject);
var
S:TStudent;
begin
s:=TStudent.Create ;
s.showinfo1 ;
s.showinfo2;
end;procedure TForm1.Button3Click(Sender: TObject);
var
W:TWorker;
begin
w:=Tworker.Create ;
w.showinfo1 ;
w.showinfo2;
end;end.