我想用Delphi作数据结构中的链表,二叉树等等,不知道怎么像C++中动态存储分配
解决方案 »
- 怎样将数据图形化,请教一个思路。
- 来看下,这是怎么回事啊?
- 求一份delphi调用webservice的代码,delphi版本越低越好最好是delphi6(能支持的话)
- 知道一个程序的句柄,怎么才能得到它的内存地址?100分,急
- 为CSDN哭泣。为中国软件技术交流环境哭泣。为delphi哭泣。
- Delphi中的crHandpoint这个光标太丑了!
- 如何用热键显示桌面??
- 怎样给树型控件绘制背景图
- 怎么让Ttreeview失去焦点后,最后选定的TREENODE还保留灰色?
- 这样的组件怎样做?
- 请问一下怎么才能看以前的帖子啊?
- 有用过 RX Library 2.75 中的 Rxrichedit 者请进
freeconstructor create;
destructor Destory;
看看帮助!
new
dispose
;调用Create完成创建;
;调用Free 完成释放;如果接点没用封成类 而是一个Record 那
;调用new 分内存
;调用dispose 释放;
如果是指针的话,可以用:分配内存:AllocMem();
释放内存: FreeMem();
type
pthrd=^tthrd;
tthrd=class(tthread)
public
constructor Create;
private
id:integer;
age:integer;
llink:pthrd;
rlink:pthrd;
protected
procedure Execute; override;
end; tthrdlist=class
public
idlabel:string;
count:integer;
function find(id:integer):pthrd;
procedure insert;
procedure delete(id:integer);
constructor create;
private
first:pthrd;
last:pthrd;
end;procedure tthrdlist.insert;
var
insertitem:tlistitem;
t1:tthrd;
begin
t1:=tthrd.create;
t1.id:=fm_time.thrdlist.count+1;
t1.age:=0;
t1.llink:=nil;
t1.rlink:=nil;
if first=nil then
first:=@t1;
t1.llink:=last;
last:=@t1;
count:=count+1;
insertitem:=fm_time.lv_cells.Items.insert(-1);
insertitem.Caption:=inttostr(t1.id);
end;然后我在用链表去访问每个线程,我不能获得里面的属性我原来是把线程的初始化放在create里,可也一样不能访问
如下:
constructor tthrd.Create;
begin
id:=fm_time.thrdlist.count+1;
age:=0;
llink:=nil;
rlink:=nil;
FreeOnTerminate := True;
inherited Create(False);
end;procedure tthrdlist.insert(thrdpoint:pthrd);
var
insertitem:tlistitem;
begin
if first=nil then
first:=thrdpoint;
thrdpoint.llink:=last;
last:=thrdpoint;
count:=count+1;
insertitem:=fm_time.lv_cells.Items.insert(-1);
insertitem.Caption:=inttostr(thrdpoint.id);
end;
插入时,
var
t1:tthrd;
begin
t1:=tthrd.Create;
fm_time.thrdlist.insert(@t1);
end;
只要离开了insert方法,就不能访问了,不知道是不是因为局部变量跳出局部过程就释放呢
望高手指教
对象用Create和Free方法连表请继承TList,自己写没有必要
该怎么作?