<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Martin Frb via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>> schrieb am Di., 22. Okt. 2024, 23:28:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is the below meant to be allowed?<br>
It compiles, it also compiles if you have no default in the base, but a <br>
default in the sub class.<br>
<br>
type<br>
TFoo = class<br>
procedure Bar (const Item: String; AnObject: TObject = nil); virtual;<br>
end;<br>
TFoo2 = class(TFoo)<br>
procedure Bar (const Item: String; AnObject: TObject); override;<br>
end;<br>
<br>
<br>
It even works with both having a diff default.<br>
<br>
TFoo = class<br>
procedure Bar (const Item: String; AnObject: integer = 1); virtual;<br>
end;<br>
TFoo2 = class(TFoo)<br>
procedure Bar (const Item: String; AnObject: integer=2); override;<br>
end;<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">A default value is not part of the signature. In the end the behavior will depend upon the concrete instance used: if youe variable is declared as TFoo then that default value will be used. If it's the first TFoo2 then the parameter is not optional and for the second TFoo2 the value passed in will be 2.</div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>