Show: Object Pascal C++
Display Preferences

E2169 Field definition not allowed after methods or properties (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Error and Warning Messages (Object Pascal) Index

You have attempted to add more fields to a class after the first method or property declaration has been encountered. You must place all field definitions before methods and properties.


program Produce;

  type
    Base = class
      procedure FirstMethod;
      a : Integer;
    end;


  procedure Base.FirstMethod;
  begin
  end;

begin
end.

The declaration of 'a' after 'FirstMethod' will cause an error.


program Solve;

  type
    Base = class
      a : Integer;
      procedure FirstMethod;
    end;


  procedure Base.FirstMethod;
  begin
  end;

begin
end.

To solve this error, it is normally sufficient to move all field definitions before the first field or property declaration.

Personal tools
In other languages