[fpc-devel] virtual override with diff in default ?
    Martin Frb 
    lazarus at mfriebe.de
       
    Tue Oct 22 23:28:03 CEST 2024
    
    
  
Is the below meant to be allowed?
It compiles, it also compiles if you have no default in the base, but a 
default in the sub class.
type
   TFoo = class
     procedure Bar (const Item: String; AnObject: TObject = nil); virtual;
   end;
   TFoo2 = class(TFoo)
     procedure Bar (const Item: String; AnObject: TObject); override;
   end;
It even works with both having a diff default.
   TFoo = class
     procedure Bar (const Item: String; AnObject: integer = 1); virtual;
   end;
   TFoo2 = class(TFoo)
     procedure Bar (const Item: String; AnObject: integer=2); override;
   end;
    
    
More information about the fpc-devel
mailing list