Hi,
i started to write an matrix unit. At the moment i am using a procedure for assignment:
procedure ma(var a:matrix; b:matrix); { b --> a }I want to overload the assign operator, but i didnt work:
Here my question: is it possible to make overloading of "assignment for equal types" and accessing to the destination variable possible?
here is a example:
type matrix=record
n,m : longint;
pa : ^double;
end;
operator := ( b : matrix ) a : matrix;
{ generates error: Impossible to overload assignment for equal types }
begin
if a.ptnil then freemem(a.pt,a.n*a.m*sozeof(double));
{ generates warning: Function result does not seem to be set }
a.n:=b.n; a.m:=b.m;
getmem(a.pt,a.n*a.m*sizeof(double));
end;Of course this would be a bad solution for a matrix unit (function results ...). But a different way (using an internal list of matrices and a counter for each list entry how often the matrix is used) makes it possible to write an comfortable matrix unit.
Stefan
