<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2013/10/25 Michael Van Canneyt <span dir="ltr"><<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im">Why not simply make it a procedure that is called by ver-2 and ver-3.<br></div>
<br>
If it cannot be called directly from external code, and will called only from inside a visible consructor, there is simply no reason to make this procedure a constructor. A simple procedure will do.<span class=""></span></blockquote>
<div><br><div class="gmail_default" style="font-family:courier new,monospace;display:inline">Because I don't know how to make it non-constructor. See the following code:<br><br> 1 unit wtree;<br> 2 {$mode objfpc}{$H+}<br>
3 interface<br> 4 uses tree;<br> 5 type<br> 6 TQWordTree = specialize TTree<QWord>;<br> 7 TWTree = class(TQWordTree)<br> 8 private<br> 9 FModel: string;<br> 10 public<br> 11 property Model: string read FModel;<br>
12 constructor Create(AData: QWord; AParent: TWTree; AModel: string);<br> 13 constructor Create(HeadNode, TailNode: QWord);<br> 14 end;<br> 15 implementation<br> 16 <br> 17 constructor TWTree.Create(AData: QWord; AParent: TWTree; AModel: string);<br>
18 begin<br> 19 inherited Create(AData, AParent);<br> 20 FModel := AModel;<br> 21 end;<br> 22 <br> 23 constructor TWTree.Create(HeadNode, TailNode: QWord);<br> 24 begin<br> 25 inherited Create(0, nil);<br> 26 Data := HeadNode;<br>
27 with TWTree do Create(TailNode, Create(HeadNode, Self, 'h'), 't');<br> 28 FModel := 'R';<br> 29 end;<br> 30 <br> 31 end.<br><br></div><div class="gmail_default" style="font-family:courier new,monospace;display:inline">
Please tell me how to deal with line 27, which called the should-be-private constructor.<br><br></div><div class="gmail_default" style="font-family:courier new,monospace;display:inline">BTW, this code uses TTree class, which is here:<br>
<br><a href="https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas">https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas</a><br><br></div><div class="gmail_default" style="font-family:courier new,monospace;display:inline">
Also, </div> <div class="gmail_default" style="font-family:courier new,monospace;display:inline">I don't understand why this does not work:<br><br>f := TFileStream.Create;<br><br>I know that TFileStream's Create require a file name parameter, but as TFileStream is inherited from TObject, which has a Create without parameter. This is why I feel that it is possible to HIDE a public constructor from ancestor.<br>
<br></div><div class="gmail_default" style="font-family:courier new,monospace;display:inline">Best Regards,<br>Xiangrong</div></div></div></div></div>