请问:怎样再DELHPI中的一个UNIT中定义一个类?(最好有实例代码)

benben1hao 2003-08-22 09:48:45
请问:怎样再DELHPI中的一个UNIT中定义一个类?(最好有实例代码)
...全文
68 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
大地精灵 2003-08-22
  • 打赏
  • 举报
回复
没有多大的问题,我就不来搅和了
mbzdh 2003-08-22
  • 打赏
  • 举报
回复
问题都解决了,恭喜!
ysycrazy 2003-08-22
  • 打赏
  • 举报
回复
var form1:tform;
begin
try
form1:=tfrom.create(application);
form1.show;
finally
from1.free;
end;
end;
vargent77 2003-08-22
  • 打赏
  • 举报
回复
定义的函数应该是:
type
TExpressionParsing=class(TObject)
public
function ExpParsing(var strExp:TExpressionParsing):float;

end;
benben1hao 2003-08-22
  • 打赏
  • 举报
回复
再请教一问:
我定义的函数为什么不能返回FLOAT类型?
代码如下:
type
TExpressionParsing=class(TObject)
public
function ExpParsing(strExp:string):float;

end;
foreveryday007 2003-08-22
  • 打赏
  • 举报
回复
clsAA: TClassAA;

clsAA := TClassAA.Create;
benben1hao 2003-08-22
  • 打赏
  • 举报
回复
再问:我定义了一个类后,怎样实例化这个类,调用类中定义的对象???????
ysycrazy 2003-08-22
  • 打赏
  • 举报
回复
unit Unit2;

interface
uses Forms;
type TMyclass=class(Tform)

end;
Student=record
xh:string;
xm:string;
nl:integer;
end;

implementation

end.
初心2 2003-08-22
  • 打赏
  • 举报
回复
unit Unit2;

interface
uses
windows,QDialogs;

type
TAdd =class
private
fminvalue:integer;
fmaxvalue:integer;
procedure setminvalue(b:integer);
procedure setmaxvalue(a:integer);
public
property minvalue:integer read Fminvalue write SetMinvalue;
property maxvalue:integer read Fmaxvalue write Setmaxvalue;
function getmaxvalue:integer;
function addall:integer;//(minvalue,maxvalue:integer):integer;
constructor Create(cc:string); overload; //构造
// destructor Destroy ;override;// 这里可以不用的吗?

end;

implementation

{ TAdd }

function TAdd.addall:integer;//(minvalue, maxvalue: integer): integer;
var
i:integer;
begin
result:=0;
for i:=minvalue to maxvalue do
begin
result:=result+i;
end;
end;





constructor TAdd.Create(cc:string);

begin
showmessage(cc);
end;

function TAdd.getmaxvalue: integer;
begin
result:=maxvalue;
end;

procedure TAdd.setmaxvalue(a:integer);
begin
Fmaxvalue:=a;
end;

procedure TAdd.setminvalue(b:integer);
begin
Fminvalue:=b;
end;

end.
牧笛李 2003-08-22
  • 打赏
  • 举报
回复
仔细看看delphi的源代码,类都是定义在unit中的。

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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