大家看看这是什么意思啊!?(100分)

  • 主题发起人 主题发起人 geekqk
  • 开始时间 开始时间
G

geekqk

Unregistered / Unconfirmed
GUEST, unregistred user!
TChannel=object
WState:integer;
chno:word;
connectch:word;
vfname:string;
bcallback:boolean;
procedure init;
procedure read;
procedure callout;
end;
这是一种什么变量定义啊!?能详细说明吗!?
 
Object和Class比较类似
不过TChannel=Object这样定义的话没有父类,需要自己使用New和Dispose创建释放
而TChannel=Class等同于TChannel=Class(TObject),父类为TObject
 
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.
 
谢谢,ic
 
后退
顶部