Can I overload operators for my own classes in Delphi?
I faced a little trouble - I do not know if I can define my own operators for my classes. For example:
type TMinMatrix = class(TMatrix) private RowAmount: Byte; ColAmount: Byte; Data: DataMatrix; DemVector, SupVector: SupplyDemand; public constructor Create(Rows, Cols: Byte); function GetRowAmount: Byte; override; function GetColAmount: Byte; override; destructor Destroy; end;
How can I - or can`t I:) - do something like:
TMinMatrix TMinMatrix::operator=(TMinMatrix* matr) (c++ code)
And, by the way, can I define copy constructor for my class?
Operator overloading is possible in Delphi .NET versions, older versions of Delphi don't support it.
Delphi Win32 2007 and 2009 only supports class operator overload for records, you can have implicit and explicit operators. Delphi .Net supports class operators for records and classes.