tw1365.pp 847 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. { %FAIL }
  2. {$mode fpc}
  3. program test_const_objects;
  4. type
  5. tobj1 = object
  6. x,y : integer;
  7. end;
  8. tobj2 = object(tobj1)
  9. z : integer;
  10. constructor init(ax,ay,az : integer);
  11. procedure display; virtual;
  12. end;
  13. tobj3 = object(tobj2)
  14. t : integer;
  15. constructor init(ax,ay,az,at : integer);
  16. procedure display; virtual;
  17. end;
  18. constructor tobj2.init(ax,ay,az : integer);
  19. begin
  20. x:=ax;
  21. y:=ay;
  22. z:=az;
  23. end;
  24. procedure tobj2.display;
  25. begin
  26. Writeln(x,' ',y,' ',z);
  27. end;
  28. constructor tobj3.init(ax,ay,az,at : integer);
  29. begin
  30. x:=ax;
  31. y:=ay;
  32. z:=az;
  33. t:=at;
  34. end;
  35. procedure tobj3.display;
  36. begin
  37. Writeln(x,' ',y,' ',z,' ',t);
  38. end;
  39. const
  40. Obj1 : Tobj1 = (x : 1; y : 2);
  41. Obj2 : TObj2 = (x : 3; y : 4; z : 5);
  42. Obj3 : Tobj3 = (x : 6; y : 7; z : 8; t : 9);
  43. begin
  44. Obj2.Display;
  45. Obj3.display;
  46. end.