The parent class has three properties.
public property Rows: integer read GetNumRows write SetNumRows; property Columns: integer read GetNumColumns write SetNumColumns; property All: VarMatrix read IRead write IRead; one of which is redefined in descendant classes:
property All: Matrix read MRead write MRead; where the Matrix type is its own, for each descendant (a two-dimensional dynamic array with elements of different types ).
There are two functions that return the length and width of the matrix and two procedures, on the contrary, which define them:
function HomerMatrix.GetNumRows:integer; begin GetNumRows := length(All); end; function HomerMatrix.GetNumColumns:integer; begin GetNumColumns := length(All[0]); end; procedure HomerMatrix.SetNumRows(NumRows:integer); begin SetLength(All, NumRows); //На эту строку ругается компилятор end; procedure HomerMatrix.SetNumColumns(NumColumns:integer); var i:integer; begin for i := 0 to Rows-1 do SetLength(All[i], NumColumns); end; All this disgrace is called from the class of the descendant as follows (for an integer matrix):
constructor HomerIntMatrix.Create(h, w, def: integer); begin Rows := h; Columns := w; DefCell := def; end; Read the length of the array-field by property is obtained, set the length of the arrays of the second level - the same, but SetNumRows gives an error:
Can't take the address of constant expressions
If you go directly to the field
SetLength(IRead, NumRows); there is no error, but I need to refer specifically to the property for the override to work.
Full code of two classes . Actually, why does this error occur, and how to get around it?
"SetLength(All, IRead);" ??? CanSetLength(IRead, NumRows);? - Igor