请各位高手看如下代码:
Tnode=class
private
Fparent:integer;
Fstr1:string;
......
end;Tnode1=class(Tnode)
private
FString2:string;
......
end;Tnode2=class(Tnode)
private
Fstring3:String;
......
end;TNodeList=class
Private
Flist:Tlist;
public
function item(index:integer):Tnode;
function indexof(Node:Tnode):integer;
....
end;
TNodeList1=class
Private
Flist:Tlist;
public
function item(index:integer):Tnode1;
function indexof(Node:Tnode1):integer;
....
end;TNodeList2=class
Private
Flist:Tlist;
public
function item(index:integer):Tnode2;
function indexof(Node:Tnode2):integer;
....
end;Tnode1, Tnode2从Tnode类继承的,TNodeList提供了对TNODE类对象管理的全部方法。现在我想对Tnode1和Tnode2也提供和 TNodeList一样的类进行管理如TNodeList1,TnodeList2等,方法ITEM和INDEXOF在类TNodeList1和 TNODELIST2中被表达为function item(index:integer):Tnode1;
function item(index:integer):Tnode2;
function indexof(Node:Tnode1):integer;
function indexof(Node:Tnode2):integer;
其他的方法和过程都和TNodeList一样。现在如果我有类TnodeLIST从1到10,我得复制10个TnodeList并只修改了Tnode为 Tnode1到Tnode10。这样不仅烦而且一旦改了管理方法之后就得改10个TNODELIST类。有没有一种简单的方法我可以只定义TNode1到 Tnode10而Tnodelist1到10可以由一个类TNodeList来实现。TnodeList1到10可以被定义为Tnodelist类型并可以管理类Tnode1到10。谢谢各位了。