2
0

tb0182.pp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. { %OPT=-St }
  2. { Old file: tbs0215.pp }
  3. { more bugss with static methods OK 0.99.11 (PM) }
  4. { allow static keyword }
  5. { submitted by Andrew Wilson }
  6. Program X;
  7. Type
  8. PY=^Y;
  9. Y=Object
  10. A : LongInt;
  11. P : PY; static;
  12. Constructor Init(NewA:LongInt);
  13. Procedure StaticMethod; static;
  14. Procedure VirtualMethod; virtual;
  15. End;
  16. Constructor Y.Init(NewA:LongInt);
  17. Begin
  18. A:=NewA;
  19. P:=@self;
  20. End;
  21. Procedure Y.StaticMethod;
  22. Begin
  23. Writeln(P^.A); // Compiler complains about using A.
  24. P^.VirtualMethod; // Same with the virtual method.
  25. With P^ do begin
  26. Writeln(A); // These two seem to compile, but I
  27. VirtualMethod; // can't get them to work. It seems to
  28. End; // be the same problem as last time, so
  29. End; // I'll check it again when I get the
  30. // new snapshot.
  31. Procedure Y.VirtualMethod;
  32. Begin
  33. Writeln('VirtualMethod ',A);
  34. End;
  35. var T1,T2 : PY;
  36. Begin
  37. New(T1,init(1));
  38. New(T2,init(2));
  39. T1^.VirtualMethod;
  40. T2^.VirtualMethod;
  41. Y.StaticMethod;
  42. T1^.StaticMethod;
  43. T2^.StaticMethod;
  44. End.