My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
Demonstrates that OOP really works in DWSII!
}

type
TClassA = class
protected
str: string;
public
constructor Create; virtual;
class procedure Test; virtual;

property strProp : String read str;
end;

type
TClassB = class(TClassA)
public
constructor Create; override;
class procedure Test; reintroduce;
end;

constructor TClassA.Create;
begin
str := 'A';
end;

class procedure TClassA.Test;
begin
PrintLn('TestA');
end;

constructor TClassB.Create;
begin
str := 'B';
end;

class procedure TClassB.Test;
begin
PrintLn('TestB');
end;

var
cls: class of TClassA;
var
o: TClassA;

cls := TClassB;
o := cls.Create;

PrintLn(o.strProp);
o.test; // call static method
TClassB(o).test;

Change log

r494 by zarglu on Feb 1, 2011   Diff
Enforce class visibility constraints
Go to: 
Project members, sign in to write a code review

Older revisions

r12 by zarglu on Aug 24, 2010   Diff
SVN initial import
All revisions of this file

File info

Size: 784 bytes, 53 lines
Powered by Google Project Hosting