Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 为什么会从基类中引发变量的运行时未知标识符错误?_.net_Derived Class_Base Class_Delphi Prism - Fatal编程技术网

.net 为什么会从基类中引发变量的运行时未知标识符错误?

.net 为什么会从基类中引发变量的运行时未知标识符错误?,.net,derived-class,base-class,delphi-prism,.net,Derived Class,Base Class,Delphi Prism,如果这个问题显得含糊不清,我道歉。这是针对Delphi Prism.NET的 我有一个基类,它有一个名为bounds的矩形类型变量。另一个类从这个类派生或继承,并可以访问基类变量边界。在设计时,编译器会识别基类中的变量边界,但在调试时,它会不断引发基类中变量边界的未知错误。因此,我的程序编译成功,但无法正确运行 下面是基类和变量: TControlObject = public class bounds:Rectangle; <<=========This is

如果这个问题显得含糊不清,我道歉。这是针对Delphi Prism.NET的

我有一个基类,它有一个名为bounds的矩形类型变量。另一个类从这个类派生或继承,并可以访问基类变量边界。在设计时,编译器会识别基类中的变量边界,但在调试时,它会不断引发基类中变量边界的未知错误。因此,我的程序编译成功,但无法正确运行

下面是基类和变量:

  TControlObject = public class
    bounds:Rectangle;     <<=========This is the Variable in question
  private
  protected
  public
  end; 
constructor TGateControl(theForm:Form);
begin
  inherited constructor(theForm);
  fInputCount := 2;
  bounds.width := bounds.Right-(bounds.left+(4 * CGridSize)); <<=======Here is where unknown identifier error is raised for bounds variable.
  bounds.Height := bounds.Bottom-(bounds.top+(3 * CGridSize));<<=======Here is where unknown identifier error is raised for bounds variable.
end;
下面是带有基类变量的派生类的构造函数:

  TControlObject = public class
    bounds:Rectangle;     <<=========This is the Variable in question
  private
  protected
  public
  end; 
constructor TGateControl(theForm:Form);
begin
  inherited constructor(theForm);
  fInputCount := 2;
  bounds.width := bounds.Right-(bounds.left+(4 * CGridSize)); <<=======Here is where unknown identifier error is raised for bounds variable.
  bounds.Height := bounds.Bottom-(bounds.top+(3 * CGridSize));<<=======Here is where unknown identifier error is raised for bounds variable.
end;
constructor控件(格式:Form);
开始
继承构造函数(theForm);
fInputCount:=2;

bounds.width:=bounds.Right-(bounds.left+(4*CGridSize)) 您需要在类的受保护部分声明变量,以使其对派生类可见。当您在没有明确说明可见性的情况下声明它时,假定您希望将其设置为私有,并且私有字段对派生类不可见。

我认为如果您没有在任何访问说明符下使用它,那么默认情况下它是公共的。我想这就是它在Delphi win32平台上的工作原理。太好了,我今天学到了一些新东西。谢谢