N
nong
Unregistered / Unconfirmed
GUEST, unregistred user!
我要写的是个复数类。
unit shu;
interface
type
Tshu = class
public
shibu,xubu:integer;//实部,虚部
public
constructor Create(a,b:integer);
function add(i:tshu):tshu;//复数加法
function sum:integer;
end;
implementation
uses
Main;
constructor Tshu.Create(a,b:integer);
begin
shibu:=a;
xubu:=b;
end;
function tshu.sum:integer;
begin
result:=shibu+xubu;//可以直接用
end;
function tshu.add(i:tshu):tshu;
begin
result.shibu:=?。shibu+i.shibu;//但是这里不能直接用,感觉要有?这个东东
result.xubu:=?。xubu+i.xubu;//this,it,self都不是,是什么?
end;
//或者有更好的写复数这个类的更好想法,帮帮忙。
//刚学delphi又没有书参考,只有上网学习,拜谢各位。
end.
unit shu;
interface
type
Tshu = class
public
shibu,xubu:integer;//实部,虚部
public
constructor Create(a,b:integer);
function add(i:tshu):tshu;//复数加法
function sum:integer;
end;
implementation
uses
Main;
constructor Tshu.Create(a,b:integer);
begin
shibu:=a;
xubu:=b;
end;
function tshu.sum:integer;
begin
result:=shibu+xubu;//可以直接用
end;
function tshu.add(i:tshu):tshu;
begin
result.shibu:=?。shibu+i.shibu;//但是这里不能直接用,感觉要有?这个东东
result.xubu:=?。xubu+i.xubu;//this,it,self都不是,是什么?
end;
//或者有更好的写复数这个类的更好想法,帮帮忙。
//刚学delphi又没有书参考,只有上网学习,拜谢各位。
end.