我想要个用类来实现的!!!!!! 象这样的 type tc=class public x,y:integer; function add; end; ... var my:tc; my=tc.create; my.x:=1; my.y:=3; result:=my.add; my.free; ...
program Project1; {$APPTYPE CONSOLE} uses SysUtils; type TAdd = class public Num1: Integer; Num2: Integer; function AddF: Integer; end;function TAdd.AddF: Integer; begin Result := Num1 + Num2; end;var MyAdd: TAdd; begin MyAdd := TAdd.Create; MyAdd.Num1 := 1; MyAdd.Num2 := 2; Write(MyAdd.AddF); Readln; // Insert user code here end.
象这样的
type tc=class
public
x,y:integer;
function add;
end;
...
var my:tc;
my=tc.create;
my.x:=1; my.y:=3; result:=my.add; my.free; ...
{$APPTYPE CONSOLE}
uses SysUtils;
type
TAdd = class
public
Num1: Integer;
Num2: Integer;
function AddF: Integer;
end;function TAdd.AddF: Integer;
begin
Result := Num1 + Num2;
end;var
MyAdd: TAdd;
begin
MyAdd := TAdd.Create;
MyAdd.Num1 := 1;
MyAdd.Num2 := 2;
Write(MyAdd.AddF);
Readln;
// Insert user code here
end.