12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- { $OPT=-St }
- { allow static keyword }
- { submitted by Andrew Wilson }
- Program X;
- {$ifdef go32v2}
- uses dpmiexcp;
- {$endif go32v2}
- 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.
|