tclass2.pp 545 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. { %VERSION=1.1 }
  2. {$mode objfpc}
  3. type
  4. to1 = class
  5. destructor destroy;override;
  6. procedure beforedestruction;override;
  7. end;
  8. var
  9. i : longint;
  10. destructor to1.destroy;
  11. begin
  12. if i<>2000 then
  13. halt(1);
  14. i:=3000;
  15. inherited destroy;
  16. end;
  17. procedure to1.beforedestruction;
  18. begin
  19. if i<>1000 then
  20. halt(1);
  21. i:=2000;
  22. end;
  23. var
  24. o1 : to1;
  25. begin
  26. o1:=to1.create;
  27. i:=1000;
  28. o1.destroy;
  29. if i<>3000 then
  30. halt(1);
  31. writeln('ok');
  32. end.