I want to have a copy procedure that is defined as virtual in the base class and implemented later in the derived class. The problem is that it is not allowed to redefine the procedure due to different parameters. Is there any solution with a Delphi class model or is my approach completely wrong?
type TCar = class procedure CopyFrom(c: TCar); virtual; end; TChrysler = class(TCar) FColor: Integer; procedure CopyFrom(c: TChrysler); override; end; procedure TCar.CopyFrom(c: TCar); begin //virtual end; procedure TChrysler.CopyFrom(c: TCrysler); begin FColor := c.FColor; end; var Car1, Car2: TCar; begin Car1 := TChrysler.Create; Car2 := TChrysler.Create; Car2.CopyFrom(Car1); //TChrysler.CopyFrom should be called. end;
source share