TChannel是类,是无父类的类,要不测试一下。
如下可以正常使用,但是在tabc加点时提示只有如上定义的变量和函数,
而ttest则有classname等等在TOBJECT父类中定义的方法属性!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TChannel=object
WState:integer;
chno:word;
connectch:word;
vfname:string;
bcallback:boolean;
procedure init;
procedure read;
procedure callout;
end;
type
ttest = class(tobject)
WState:integer;
chno:word;
connectch:word;
vfname:string;
bcallback:boolean;
procedure init_a;
procedure read_b;
procedure callout_c;
end;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TChannel }
procedure TChannel.callout;
begin
showmessage('callout');
end;
procedure TChannel.init;
begin
showmessage('init');
end;
procedure TChannel.read;
begin
showmessage('read');
end;
procedure TForm1.Button1Click(Sender: TObject);
var
tabc : TChannel;
ttest_a : ttest;
begin
tabc.init;
tabc.read;
tabc.callout;
ttest_a.init_a;
ttest_a.read_b;
ttest_a.callout_c;
showmessage(ttest_a.ClassName);
end;
{ ttest }
procedure ttest.callout_c;
begin
showmessage('c');
end;
procedure ttest.init_a;
begin
showmessage('a');
end;
procedure ttest.read_b;
begin
showmessage('b');
end;
end.