Razir66
Razir66

Reputation: 118

Error overloading procedure in Delphi

For some reason I am now getting this error '[DCC Error] MyFile.pas(52): E2137 Method 'Assign' not found in base class'. Here is a snipit of my Assign procedures that worked fine until I added one more, the last Assign.

procedure Assign(MyClass: TMyClass); overload; override;
procedure Assign(MyClass: ThisService.MyClass); overload; override;
procedure Assign(MyClass: ThatService.MyClass); overload; override;
procedure Assign(MyClass: TXMLMyClass); overload; override;
procedure Assign(MyClass: pbStruct1Messages.TMyRecord); overload; override;
procedure Assign(MyClass: pbStruct2Messages.TMyRecord); overload; override;

Upvotes: 3

Views: 915

Answers (2)

Rob Kennedy
Rob Kennedy

Reputation: 163247

When you use override, you're saying that you're overriding the virtual method with the same signature inherited from a parent class. If the parent class doesn't have a virtual method with that signature, then the compiler will rightly complain that it can't find it.

Check the ancestor classes to confirm that the method really exists. If it doesn't exist, then don't mark the one in the descendant class with override.

Upvotes: 5

ar_gentum
ar_gentum

Reputation: 1

procedure Assign(MyClass: pbStruct1Messages.TMyClass); overload; override;
procedure Assign(MyClass: pbStruct2Messages.TMyClass); overload; override;

I think thihs is error, you make two equals parameter TMyClass. Use somelike

procedure Assign(MyClass: pbStruct1Messages); overload; override;
procedure Assign(MyClass: pbStruct2Messages); overload; override;

Upvotes: -3

Related Questions