<div dir="ltr"><div class="gmail_default" style="font-family:'courier new',monospace">Hi All,</div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default" style="font-family:'courier new',monospace">

According to <a href="http://www.freepascal.org/docs-html/ref/refsu72.html">http://www.freepascal.org/docs-html/ref/refsu72.html</a>,<br></div><div class="gmail_default" style="font-family:'courier new',monospace">

<br></div><div class="gmail_default" style="font-family:'courier new',monospace">the overload keyword is mostly optional and for delphi compatiblity only. But on Oct. 27, Sven replied my question about hide a public constructor in base class:</div>

<div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default" style="font-family:'courier new',monospace"><p style="font-family:arial,sans-serif;font-size:14px">

<span style="color:rgb(80,0,80)">>>  I don't understand why this does not work:</span><br></p><div class="im" style="font-family:arial,sans-serif;font-size:14px">>> f := <span class="" style="background-color:rgb(255,255,204);color:rgb(34,34,34)">TFileStream</span>.Create;<br>

>><br>>> I know that <span class="" style="background-color:rgb(255,255,204);color:rgb(34,34,34)">TFileStream</span>'s Create require a file name parameter, but as <span class="" style="background-color:rgb(255,255,204);color:rgb(34,34,34)">TFileStream</span> is</div>

<div class="im" style="font-family:arial,sans-serif;font-size:14px">>> inherited from TObject, which has a Create without parameter.  This is why I feel that it </div><div class="im" style="font-family:arial,sans-serif;font-size:14px">

>> is possible to HIDE a public constructor from ancestor.</div><div class="im" style="font-family:arial,sans-serif;font-size:14px"><span style="color:rgb(34,34,34)"><br></span></div><div class="im" style="font-family:arial,sans-serif;font-size:14px">

> <span style="color:rgb(34,34,34)">No, I don't think so. If you want users to use the original constructor as well you'd need to </span></div><div class="im" style="font-family:arial,sans-serif;font-size:14px">

<span style="color:rgb(34,34,34)">> declare yours as "overload". If it would be possible to call</span><span style="color:rgb(34,34,34)"> </span><span class="" style="color:rgb(34,34,34);background-color:rgb(255,255,204)">TFileStream</span><span style="color:rgb(34,34,34)">.Create without </span></div>

<div class="im" style="font-family:arial,sans-serif;font-size:14px"><span style="color:rgb(34,34,34)">> parameters then the instance would be in an inconsistent state, so only calling the</span></div><div class="im" style="font-family:arial,sans-serif;font-size:14px">

<span style="color:rgb(34,34,34)">> constructor with arguments should be possible (which is the case for</span><span style="color:rgb(34,34,34)"> </span><span class="" style="color:rgb(34,34,34);background-color:rgb(255,255,204)">TFileStream</span><span style="color:rgb(34,34,34)">.</span><br>

</div><p style="font-family:arial,sans-serif;font-size:14px">> So this is definitely by design.</p><p style="font-family:arial,sans-serif;font-size:14px">Now my question is: in this case overload keyword DO make a difference? Then, how to overload? e.g.:</p>

<p style="font-family:arial,sans-serif;font-size:14px">In base class:</p><p style="font-family:arial,sans-serif;font-size:14px">constructor Create;</p><p style="font-family:arial,sans-serif;font-size:14px">In child class:</p>

<p style="font-family:arial,sans-serif;font-size:14px">constructor Create(param1:...; param2: ...): overload;</p><p style="font-family:arial,sans-serif;font-size:14px">i.e. overload does NOT require functions to have same parameter list or return type? Also, it does not require the overload keyword in base class? Otherwise programmers need to modify the base class, which is not good.</p>

<p style="font-family:arial,sans-serif;font-size:14px">Thanks,</p><p style="font-family:arial,sans-serif;font-size:14px">Xiangrong</p></div></div>