Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having difficulties understanding the difference between the following (similar) procedure definitions. Also I'm wondering how to determine when and why to use the 2nd definition.

#1 - Standard routine definition
type
  TFigure = class
  public
     function Supports(Operation: string): Boolean; virtual;
     procedure GetInfo(var Info: TFigureInfo); virtual;
     ...
  end;


#2 - routine prefaced by the keyword "class"
type
  TFigure = class
  public
     class function Supports(Operation: string): Boolean; virtual;
     class procedure GetInfo(var Info: TFigureInfo); virtual;
     ...
  end;


What I have tried:

I've googled this topic and cannot find a simple, direct definition of when/why to use the "class" keyword.

The 2 examples in my question were taken from the Embarcadero website - I just removed the "class" for example #1. I did not see any documentation re: the specific differences or when/why to preface with the keyword "class".

This has been bugging me for quite a while now and any clarification is greatly appreciated.

b.
Posted
Updated 20-Jul-18 1:43am

1 solution

The methods (procedures / functions) without the "class" specifier are normal methods that are a part of any INSTANCE of a class, whereas those with the "class" specifier are methods of the class itself, and not of an INSTANCE of the class.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900