Meraqp
Meraqp

Reputation: 161

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?

Upvotes: 3

Views: 2844

Answers (2)

Larry
Larry

Reputation: 11

Actually, Delphi-6 supports class variables. For example, you can do this:

var CV: TClass;

CV:=TCheckBox;

if CV=TCheckBox then ...;

Upvotes: -2

Rob Kennedy
Rob Kennedy

Reputation: 163257

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.

Upvotes: 8

Related Questions