代码如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TSchool=class
public
Name:string;
function GetKind:string;virtual;
end; THighSchool=class(TSchool)
public
ClassCounts:Word;
function GetKind:string;override;
end; TUniversity=class(TSchool)
public
facultyCounts:word;
function GetKind:string;override;
end;
TForm1 = class(TForm)
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Button1: TButton;
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure formcreate(Sender: TObject);
private
AScool:TSchool;(AScool放在private和public以及var处的作用域范围分别是怎样?TKS!!!)
public end;var
Form1: TForm1;
implementation
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TSchool=class
public
Name:string;
function GetKind:string;virtual;
end; THighSchool=class(TSchool)
public
ClassCounts:Word;
function GetKind:string;override;
end; TUniversity=class(TSchool)
public
facultyCounts:word;
function GetKind:string;override;
end;
TForm1 = class(TForm)
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Button1: TButton;
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure formcreate(Sender: TObject);
private
AScool:TSchool;(AScool放在private和public以及var处的作用域范围分别是怎样?TKS!!!)
public end;var
Form1: TForm1;
implementation
放在下面就可以了
在其他单元可以通过Form1.AScool来调用(不过不要忘记在其他单元中uses Unit1)如果放在private里面,在其他单元中,这个变量是不可见的