E2075 This form of method call only allowed in methods of derived types (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Error and Warning Messages (Delphi)

This error message is issued if you try to make a call to a method of an ancestor type, but you are in fact not in a method.


program Produce;

type
  TMyClass = class
    constructor Create;
  end;

procedure Create;
begin
  inherited Create;      (*<-- Error message here*)
end;

begin
end.

The example tries to call an inherited constructor in procedure Create, which is not a method.


program Solve;

type
  TMyClass = class
    constructor Create;
  end;

constructor TMyclass.Create;
begin
  inherited Create;
end;

begin
end.

The solution is to make sure you are in fact in a method when using this form of call.