小编Mek*_*cha的帖子

delphi类中的访问冲突

我有一个这样的课:

Component = class(TObject)  
  Name: string;               
  CurState: word;             
  States: array of state;   
  constructor Create(nm: string);
  procedure AddState(ccl: bool; const InB: BufArr; const OutB: BufArr);
  function GetStateCount(): Integer;
  end;
Run Code Online (Sandbox Code Playgroud)

States是一个数组state,也是一个类声明.

 State = class(TObject)    
  InBuf: BufArr;            
  OutBuf: BufArr;           
  Cycle: bool;       
  constructor Create(ccl: bool; const InB: BufArr; const OutB: BufArr);
  end;
Run Code Online (Sandbox Code Playgroud)

每个都component可以容纳多个state,这就是为什么我有一个数组state.

GetStateCount()函数应返回组件所具有的状态数.实现如下:

function Component.GetStateCount(): Integer;
begin
  result:=Length(States);
end;
Run Code Online (Sandbox Code Playgroud)

但是,当我在另一个过程中调用此函数时,我收到以下错误:

在此输入图像描述

我似乎无法弄清楚这个原因.将不胜感激任何帮助.

好的,这是我调用函数的代码的一部分:

for i:=0 to nc-1 do
begin
cycle:=false;
len:=cmp[i].GetStateCount;
for j:=0 …
Run Code Online (Sandbox Code Playgroud)

delphi class delphi-7 access-violation

0
推荐指数
1
解决办法
1149
查看次数

标签 统计

access-violation ×1

class ×1

delphi ×1

delphi-7 ×1