我用的是Lazarus,按照它的help文档中写了一个类的声明,但是编译器却报错,代码如下:
type
  MyClass = Class
    Private
      Field1 : Longint;
      Field2 : Longint;
      Field3 : Longint;
      Procedure Sety(value : Longint);
      Function Gety : Longint;
      Function Getz : Longint;
    Public
      Property X : Longint Read Field1 Write Field2;
      Property Y : Longint Read GetY Write Sety;
      Property Z : Longint Read GetZ;
  end;error message:unit1.pas(32,17) Error: Forward declaration not solved "MyClass.Sety(LongInt);"
              unit1.pas(33,16) Error: Forward declaration not solved "MyClass.Gety:LongInt;"
              unit1.pas(33,16) Error: Forward declaration not solved "MyClass.Gety:LongInt;"
这是怎么错了?我只在这个类里面作了声明啊!class

解决方案 »

  1.   

    Procedure Sety(value : Longint);
    Function Gety : Longint;
    Function Getz : Longint;
    只见声明没见实现部份
      

  2.   

    type
      MyClass = class
      private
        Field1: Longint;
        Field2: Longint;
        Field3: Longint;
        procedure Sety(value: Longint);
        function Gety: Longint;
        function Getz: Longint;
      public
        property X: Longint read Field1 write Field2;
        property Y: Longint read GetY write Sety;
        property Z: Longint read GetZ;
      end;
    var
      Form1: TForm1;implementation{$R *.dfm}procedure Myclass.Sety(value: LongInt);
    begin
      if value >0 then
        Field1 := value;
    end;function Myclass.Gety: Longint;
    begin
      Result := Field2;
    end;function myclass.Getz: Longint;
    begin
      result := Field3;
    end;
      

  3.   


    还有请问一个这种类属性的声明方式代表什么意思如:
    Property CommaText:string read GetCommaText write SetCommaText;我用的是Lazarus,它的帮助文档我没怎么看明白,不过帮助文档里好像说这种方式Delphi里是不支持的,不知你知不知道它的含义是什么,谢谢!!!
      

  4.   

    这个好像有点小问题咧,按照你这个写后出现了如下报错:
    unit1.pas(59,23) Error: Fields cannot appear after a method or propertydefinition, start a new visibility section first
    unit1.pas(59,19) Error: function header doesn't match the previous declaration "MyClass.Gety:LongInt;"