blob: ff00b4f7118dd363d3e90e5a2f01431167942dd7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
program tclass9;
{$ifdef fpc}
{$mode delphi}{$H+}
{$endif}
{$APPTYPE CONSOLE}
type
TSomeClass = class
private
type
TSomeType = type integer; // an internal type
class var
FSomeClassVar: TSomeType; // class variable belongs to class, not an instance
var
FSomeIntanceVar: TSomeType; // instance variable belongs to instance. it is a usual field
class procedure SetSomeClassVar(const AValue: TSomeType); static;
public
class property SomeProperty: TSomeType read FSomeClassVar write SetSomeClassVar; // class property - belongs to class
property SomeInstanceProp: TSomeType read FSomeIntanceVar;
end;
{ TSomeClass }
class procedure TSomeClass.SetSomeClassVar(const AValue: TSomeType);
begin
FSomeClassVar := AValue;
end;
var
SomeClass: TSomeClass;
begin
SomeClass.SomeProperty := 1;
WriteLn(SomeClass.SomeProperty);
end.
|