1
General / Re: Initiaiizing records by constructor
« Last post by ASerge on Today at 01:58:30 pm »According to the official documentation Extended record type definition, "Constructors or destructors cannot be defined".
But this is allowed in Delphi. As a result, FPC has allowed this as well, but uses them as for classes, not as for objects.
For classes, the expression "a.Create(i,s)" is an erroneous expression. The constructor call must be assigned to a variable.
For objects (TA = object...) it is acceptable to call the constructor as a regular method.
So the choice is yours:
1. Use the constructor call form as for a class: Variable := a.Create(i,s).
2. Use an object instead of a record.
3. Change the constructor to the usual procedure.
But this is allowed in Delphi. As a result, FPC has allowed this as well, but uses them as for classes, not as for objects.
For classes, the expression "a.Create(i,s)" is an erroneous expression. The constructor call must be assigned to a variable.
For objects (TA = object...) it is acceptable to call the constructor as a regular method.
So the choice is yours:
1. Use the constructor call form as for a class: Variable := a.Create(i,s).
2. Use an object instead of a record.
3. Change the constructor to the usual procedure.