Hi,
In my TTree class:
https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas
I have the following method:
function TTree.Load(s: TStream): Integer;
var
lv, c: QWord;
node: TTree;
buf: Pointer;
begin
Clear;
if not ReadNodeData(s, lv, buf, c) then Exit(0);
DoRestore(buf);
OnRestore; //<-- CALL#1
FreeMem(buf, c);
Result := 1;
node := Self;
while ReadNodeData(s, lv, buf, c) do begin
while (node <> nil) and (lv < node.Level) do node := node.Parent;
if (lv = node.Level) and (node <> Self) then
node := TTree.Create(Data, node.Parent)
else
node := TTree.Create(Data, node);
node.DoRestore(buf);
node.OnRestore; //<-- CALL#2
FreeMem(buf, c);
Inc(Result);
end;
end;
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.
How to solve this problem?
Thanks!
Xiangrong
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal