<div dir="ltr"><div class="gmail_default" style="font-family:'courier new',monospace">Hi,</div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default" style="font-family:'courier new',monospace">
In my TTree class: <a href="https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas" style="font-family:arial">https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas</a></div><div class="gmail_default" style="font-family:'courier new',monospace">
<br></div><div class="gmail_default" style="font-family:'courier new',monospace">I have the following method:</div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default">
<div class="gmail_default"><font face="courier new, monospace">function TTree.Load(s: TStream): Integer;</font></div><div class="gmail_default"><font face="courier new, monospace">var</font></div><div class="gmail_default">
<font face="courier new, monospace"> lv, c: QWord;</font></div><div class="gmail_default"><font face="courier new, monospace"> node: TTree;</font></div><div class="gmail_default"><font face="courier new, monospace"> buf: Pointer;</font></div>
<div class="gmail_default"><font face="courier new, monospace">begin</font></div><div class="gmail_default"><font face="courier new, monospace"> Clear;</font></div><div class="gmail_default"><font face="courier new, monospace"> if not ReadNodeData(s, lv, buf, c) then Exit(0);</font></div>
<div class="gmail_default"><font face="courier new, monospace"> DoRestore(buf);</font></div><div class="gmail_default"><font face="courier new, monospace"> OnRestore; //<-- CALL#1</font></div><div class="gmail_default">
<font face="courier new, monospace"> FreeMem(buf, c);</font></div><div class="gmail_default"><font face="courier new, monospace"> Result := 1;</font></div><div class="gmail_default"><font face="courier new, monospace"> node := Self;</font></div>
<div class="gmail_default"><font face="courier new, monospace"> while ReadNodeData(s, lv, buf, c) do begin</font></div><div class="gmail_default"><font face="courier new, monospace"> while (node <> nil) and (lv < node.Level) do node := node.Parent;</font></div>
<div class="gmail_default"><font face="courier new, monospace"> if (lv = node.Level) and (node <> Self) then</font></div><div class="gmail_default"><font face="courier new, monospace"> node := TTree.Create(Data, node.Parent)</font></div>
<div class="gmail_default"><font face="courier new, monospace"> else</font></div><div class="gmail_default"><font face="courier new, monospace"> node := TTree.Create(Data, node);</font></div><div class="gmail_default">
<font face="courier new, monospace"> node.DoRestore(buf);</font></div><div class="gmail_default"><font face="courier new, monospace"> node.OnRestore; //<-- CALL#2</font></div><div class="gmail_default"><font face="courier new, monospace"> FreeMem(buf, c);</font></div>
<div class="gmail_default"><font face="courier new, monospace"> Inc(Result);</font></div><div class="gmail_default"><font face="courier new, monospace"> end;</font></div><div class="gmail_default"><font face="courier new, monospace">end; </font></div>
<div class="gmail_default"><font face="courier new, monospace"><br></font></div><div class="gmail_default"><font face="courier new, monospace">Now I have a problem. CALL#1 is virtual as expected (sub-class's OnRestore is called), but CALL#2 is not virtual, it just call the (empty) OnRestore method defined in TTree.</font></div>
<div class="gmail_default"><font face="courier new, monospace"><br></font></div><div class="gmail_default"><font face="courier new, monospace">How to solve this problem?</font></div><div class="gmail_default"><font face="courier new, monospace"><br>
</font></div><div class="gmail_default"><font face="courier new, monospace">Thanks!</font></div><div class="gmail_default"><font face="courier new, monospace">Xiangrong</font></div></div></div>