tw0807.pp 893 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. { %FAIL }
  2. {$mode objfpc}
  3. Program test;
  4. uses crt;
  5. type
  6. TMatrix = class
  7. Constructor Create;
  8. private
  9. Elements : array [1..10,1..10] of real;
  10. end;
  11. Constructor TMatrix.Create;
  12. begin
  13. end;
  14. OPERATOR :=(r:Real):TMatrix;
  15. BEGIN
  16. WITH RESULT DO
  17. BEGIN
  18. { Do something }
  19. END;
  20. writeln ('Call to overloaded operator :=, real operand');
  21. END;
  22. operator :=(m : TMatrix):TMatrix;
  23. BEGIN
  24. WITH RESULT DO
  25. BEGIN
  26. { Do something }
  27. END;
  28. writeln ('Call to overloaded operator :=, matrix operand');
  29. END;
  30. var
  31. m : TMatrix;
  32. m2 : TMatrix;
  33. begin
  34. clrscr;
  35. writeln ('Performing calculations...');
  36. m:=TMatrix.Create;
  37. m2:=TMatrix.Create;
  38. writeln ('Assigning real to matrix...');
  39. { This one works }
  40. m:=1;
  41. writeln ('Assigning matrix to matrix...');
  42. { This one does not work }
  43. m:=m2;
  44. writeln ('Done.');
  45. end.