Delphi中对象和类的问题
unitcal;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,For...
unit cal;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
OperatorNone = WM_USER+100; //定义无任何操作
OperatorAdd = WM_USER+101; //定义加法操作
OperatorSub = WM_USER+102; //定义减法操作
OperatorMul =WM_USER+103; //定义乘法操作
OperatorDiv =WM_USER+104; //定义除法操作
type
TForm1 = class(TForm)
B_One: TButton;
B_Two: TButton;
B_Three: TButton;
B_Four: TButton;
B_Five: TButton;
B_Six: TButton;
B_Seven: TButton;
Screen: TEdit;
procedure ClearEntry();
procedure FormCreate(Sender: TObject);
procedure B_OneClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
mAccumulator:double; //暂时累加器
nAccumulator:double; //当前累加器
nDecimal:integer; //当前的小数点位置
nPreviousOperation:integer; //if true,清累加器
nClear:Boolean;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); //为什么是TForm1而不是Form1??
begin
mAccumulator:=0;
nAccumulator:=0;
nDecimal:=0;
nPreviousOperation:=OperatorNone;
nClear:=false;
end;
如注释中提到的,TForm1是类,Form1才是对象,用的时候不是应该用对象么?怎么成类了? 展开
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
OperatorNone = WM_USER+100; //定义无任何操作
OperatorAdd = WM_USER+101; //定义加法操作
OperatorSub = WM_USER+102; //定义减法操作
OperatorMul =WM_USER+103; //定义乘法操作
OperatorDiv =WM_USER+104; //定义除法操作
type
TForm1 = class(TForm)
B_One: TButton;
B_Two: TButton;
B_Three: TButton;
B_Four: TButton;
B_Five: TButton;
B_Six: TButton;
B_Seven: TButton;
Screen: TEdit;
procedure ClearEntry();
procedure FormCreate(Sender: TObject);
procedure B_OneClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
mAccumulator:double; //暂时累加器
nAccumulator:double; //当前累加器
nDecimal:integer; //当前的小数点位置
nPreviousOperation:integer; //if true,清累加器
nClear:Boolean;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); //为什么是TForm1而不是Form1??
begin
mAccumulator:=0;
nAccumulator:=0;
nDecimal:=0;
nPreviousOperation:=OperatorNone;
nClear:=false;
end;
如注释中提到的,TForm1是类,Form1才是对象,用的时候不是应该用对象么?怎么成类了? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询