W
waterflow
Unregistered / Unconfirmed
GUEST, unregistred user!
想建立一个类(队列)可是问题乖乖的
代码如下:
type ReceivePoint=^TReceivePoint;
TReceivePoint=Record
Info:String; //消息内容
Next:ReceivePoint;
Pre:ReceivePoint;
End;
type
//TReceiveQueue = class
TReceiveQueue = class(TObject)
//Head,Tail:ReceivePoint;
private
{ Private declarations }
Head,Tail:ReceivePoint;
public
{ Public declarations }
constructor Create;
destructor Destroy;
Procedure Insert(InPoint:ReceivePoint);
Procedure Delete();
function GetHead():ReceivePoint;
Function GetTail():ReceivePoint;
end;
constructor TReceiveQueue.Create;
begin
//inherited Create();
//my code
New(Head);//此处报访问内存错误,受不了,难道非要控件?
//如何实现?我有点不大想看文档了
Head.Next:=nil;
Head.Pre:=nil;
Head.Info:='';
tail:=head;
end;
destructor TReceiveQueue.Destroy;
begin
//my code
Dispose(Head);
inherited Destroy();//这边有没有问题?
end;
....
代码如下:
type ReceivePoint=^TReceivePoint;
TReceivePoint=Record
Info:String; //消息内容
Next:ReceivePoint;
Pre:ReceivePoint;
End;
type
//TReceiveQueue = class
TReceiveQueue = class(TObject)
//Head,Tail:ReceivePoint;
private
{ Private declarations }
Head,Tail:ReceivePoint;
public
{ Public declarations }
constructor Create;
destructor Destroy;
Procedure Insert(InPoint:ReceivePoint);
Procedure Delete();
function GetHead():ReceivePoint;
Function GetTail():ReceivePoint;
end;
constructor TReceiveQueue.Create;
begin
//inherited Create();
//my code
New(Head);//此处报访问内存错误,受不了,难道非要控件?
//如何实现?我有点不大想看文档了
Head.Next:=nil;
Head.Pre:=nil;
Head.Info:='';
tail:=head;
end;
destructor TReceiveQueue.Destroy;
begin
//my code
Dispose(Head);
inherited Destroy();//这边有没有问题?
end;
....