can you describe the use case you have in mind because all the above answers are correct.
I still think you do not know what class methods do...
I think I know what class methods do. I understand all the examples, except following.
type
TMyClass = class
private
a, b : integer;
public
procedure ShowValue(AValue: integer);
end;
implementation
class procedure TMyClass.ShowValue(AValue: integer); // in the type definition, this is not class procedure
begin
if Self <> nil then {Self.}A := AValue; // this doesn't work as A is not a class field.
ShowMessage(IntToStr(AValue));
end;
In the above example, I think Martin missed declaring var a and procedure ShowValue as class var and class procedure.
Use case... I wrote many methods (not class methods) for class, and the data (field values) are stored in database. And now I'd like to call some methods without creating the object, only with a few field data from DB. Of course I can create a dummy object, but looking for other ways. I'm thinking of SELECTing only necessary fields, and defining the methods as class methods so that I do not have to create dummy object. I might have to define some of the fields as class var as well.
I may define the methods as general independent function/procedure, but those methods had better be linked to the class, as I told. For example, when there are any changes in the DB structure, it's better to keep those methods within classes rather than defined as independent function/procedure, from maintenance point of view.
This is for my cognition, not for computing efficiency. I'm at the stage of pondering, not doing anything yet.
This may not be the intended purpose of class methods, but I don't think we have to be functionally fixed. We can step on a stool to exchange a bulb, not only sit on it.