tw0825.pp 563 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. {$mode tp}
  2. { args for destructors
  3. are allowed in TP mode for compatibility only PM }
  4. program test_destructor_with_args;
  5. var
  6. z : longint;
  7. type
  8. tt = object
  9. constructor dummy;
  10. destructor done(x : longint);virtual;
  11. end;
  12. constructor tt.dummy;
  13. begin
  14. end;
  15. destructor tt.done;
  16. begin
  17. Writeln('x in tt.done is ',x);
  18. z:=x;
  19. end;
  20. var
  21. pt : ^tt;
  22. begin
  23. Writeln('ln(5)=',ln(5));
  24. new(pt,dummy);
  25. pt^.done(4);
  26. if z<>4 then
  27. Halt(1);
  28. pt^.dummy;
  29. dispose(pt,done(5));
  30. if z<>5 then
  31. Halt(1);
  32. end.