tb0182.pp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. {$ifdef go32v2}
  8. uses dpmiexcp;
  9. {$endif go32v2}
  10. Type
  11. PY=^Y;
  12. Y=Object
  13. A : LongInt;
  14. P : PY; static;
  15. Constructor Init(NewA:LongInt);
  16. Procedure StaticMethod; static;
  17. Procedure VirtualMethod; virtual;
  18. End;
  19. Constructor Y.Init(NewA:LongInt);
  20. Begin
  21. A:=NewA;
  22. P:=@self;
  23. End;
  24. Procedure Y.StaticMethod;
  25. Begin
  26. Writeln(P^.A); // Compiler complains about using A.
  27. P^.VirtualMethod; // Same with the virtual method.
  28. With P^ do begin
  29. Writeln(A); // These two seem to compile, but I
  30. VirtualMethod; // can't get them to work. It seems to
  31. End; // be the same problem as last time, so
  32. End; // I'll check it again when I get the
  33. // new snapshot.
  34. Procedure Y.VirtualMethod;
  35. Begin
  36. Writeln('VirtualMethod ',A);
  37. End;
  38. var T1,T2 : PY;
  39. Begin
  40. New(T1,init(1));
  41. New(T2,init(2));
  42. T1^.VirtualMethod;
  43. T2^.VirtualMethod;
  44. Y.StaticMethod;
  45. T1^.StaticMethod;
  46. T2^.StaticMethod;
  47. End.