我有类型


TNotifyReply = class(TCollectionItem)
TNotifyReplylist = class(TOwnedCollection)


NotifyReplylist:= TNotifyReplylist.Create(self,TNotifyReply);

调用此函数后(任意次数),计数仍为零

function TNotifyReplylist.addItem: TNotifyReply;
 begin
   Result := inherited Add as TNotifyReply;
   OutputDebugString(PAnsiChar('Count > '+ inttostr(count)));
 end;


知道这里发生了什么吗?

最佳答案

发现了问题TNotifyReply.Create是

constructor TNotifyReply.Create(ACollection: TCollection);
begin
  inherited Create(Collection);
  ....


变成

inherited Create(ACollection);

09-26 18:58