tbug807.pp 883 B

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