E2261 implements 節は読み出し可能プロパティにしか許されていません (Delphi)

提供: RAD Studio
移動先: 案内検索

エラーと警告のメッセージ(Delphi) への移動

インターフェースを実装しようとしている「書き込み専用」プロパティがあります。implements 節を使用するためにはプロパティは読み出し/書き込み可能でなければなりません。


program Produce;
type
  IMyInterface = interface
  end;

  TMyClass = class(TInterfacedObject, IMyInterface)
    FMyInterface: IMyInterface;
    property MyInterface: IMyInterface implements IMyInterface;
  end;
end.


{ この例のプロパティは書き込み専用で,インターフェースの実装には使用できない }


program Solve;
type
  IMyInterface = interface
  end;

  TMyClass = class(TInterfacedObject, IMyInterface)
    FMyInterface: IMyInterface;
    property MyInterface: IMyInterface read FMyInterface implements IMyInterface;
  end;
end.


{ read 節を追加すると,プロパティは implements 節を使用することができる }