Search code examples
delphidelphi-7

Class variables in Delphi 7


Following is the code in which I try to declare class variable:

  type TMyClass = class

  private
    class function ABC(myID : integer): string;
  public
    class var s: String;
    class function XYZ: string;
  end;

I am getting error: PROCEDURE or FUNCTION expected. Is there any change in syntax of class variable in Delphi 7?


Solution

  • Delphi 7 didn't support class variables. You'll have to find another way of solving your problem. An easy fix is probably just to make it be a global variable of the enclosing unit instead.