May 2004
Intermediate to advanced
888 pages
22h 31m
English
One simple rule about constructors in Delphi for .NET is different from Delphi Win32. You cannot access class members from inherited classes prior to calling the inherited constructor. This will result in a compile-time error. You can access members of the class itself. So, for the given classes, the comments annotate the valid and invalid statements within the constructor.
TMyBase = class(TObject) FBaseField: integer; end; TMyObject = class(TMyBase) FMyObjectField: integer; constructor Create; end;
The implementation of the preceding constructor above would be
constructor TMyObject.Create; begin FBaseField := 3; // error FMyObjectField := 3; // valid inherited; FBaseField := 3; // valid FMyObjectField := 3; // valid end;
Read now
Unlock full access