blob: 1a62f3dea133accd3c44f0887cfc28cd07964e49 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
{ Old file: tbs0215.pp }
{ more bugss with static methods OK 0.99.11 (PM) }
{ allow static keyword }
{ submitted by Andrew Wilson }
Program X;
Type
PY=^Y;
Y=Object
A : LongInt;
P : PY; static;
Constructor Init(NewA:LongInt);
Procedure StaticMethod; static;
Procedure VirtualMethod; virtual;
End;
Constructor Y.Init(NewA:LongInt);
Begin
A:=NewA;
P:=@self;
End;
Procedure Y.StaticMethod;
Begin
Writeln(P^.A); // Compiler complains about using A.
P^.VirtualMethod; // Same with the virtual method.
With P^ do begin
Writeln(A); // These two seem to compile, but I
VirtualMethod; // can't get them to work. It seems to
End; // be the same problem as last time, so
End; // I'll check it again when I get the
// new snapshot.
Procedure Y.VirtualMethod;
Begin
Writeln('VirtualMethod ',A);
End;
var T1,T2 : PY;
Begin
New(T1,init(1));
New(T2,init(2));
T1^.VirtualMethod;
T2^.VirtualMethod;
Y.StaticMethod;
T1^.StaticMethod;
T2^.StaticMethod;
End.
|