请各位高手看如下代码:
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。谢谢各位了。
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。谢谢各位了。
解决方案 »
- 听说有个国产的易语言,不知道怎么样?
- listview组件中如何实现分组及折叠
- 求delphi自带一简单函数,解决马上给分!
- 急急我是初学者请问:用delphi如何写控件,在delphi中怎样用ListView,最好给一些例程看看。
- Invalid pointer operation问题,在线等待.
- spcomm编的串口程序,如果判断串口未插设备?
- Delphi5 代码转 C++ Builder5-6,请各位跨越这个界限的高手看看,谢谢!
- treeview中怎样从子节点,一次性直接获得某一个level的祖先节点?
- 急求 Delphi7第三方控件路径问题
- 存储过程这样写行不行呢?
- 查看DLL文件原码
- 我用delphi 的 clientsocket 与c builder的serversocket 通信 困惑
其它TNode1,TNode2...继承TNode
用的时候强制转换一下