Comming from a C# background I'm trying to learn Delphi. I encounter an Access violation when in my form I press a button that creates a TLight instance. Wherever I try to access my private FState I get an access violation.
What am I missing?
unit Light;
interface
uses sysUtils;
type
TLightStates = (Red, Orange, Green);
type
TLight = class
private
Fstate : TLightStates;
published
Constructor Create(); overload;
procedure SetState(const Value: TLightStates);
Property State : TLightStates
read Fstate
write SetState;
end;
implementation
{ TLight }
constructor TLight.Create;
begin
Fstate := TLightStates.Red;
end;
procedure TLight.SetState(const Value: TLightStates);
begin
Fstate := Value;
end;
end.