这好象应该写函数更好吧。
Function plus(a,b:Integer):Integer;
var
   c:Integer;
begin
……          //判断
c:=a+b;
Result:=c;
end;

解决方案 »

  1.   

    说实话,我就是想学学DELPHI的类,可是找不到好的资料555555555555
      

  2.   

    我想要个用类来实现的!!!!!!
    象这样的
    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; ...
      

  3.   

    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.
      

  4.   

    我看了上面的代码很高兴,因为我最近在学pascal中的记录类型,因为类和记录非常像。
      

  5.   

    要是吧 num1和num2放到私有类中呢???