//想定义一个栈类,结果一进栈就出错
type
Stack = class
private
Top,MaxSize : integer;
RealChar : Array[1..30] of Real; public
constructor Creat ;
destructor Destory ;
function Pop : Real;
procedure Push(var s : Real) ;
function IsEmpty : Boolean;
function IsFull : Boolean;
end;constructor Stack.Creat ;
begin
Top := 0;
MaxSize := 30;
end;destructor Stack.Destory ;
begin
Top := 0;
end;function Stack.IsEmpty : Boolean;
begin
if Top = 0 then
result := True
else
result := False;
end;function Stack.IsFull : Boolean;
begin
if Top >= 30 then
result := True
else
result := False;
end;function Stack.Pop : Real;
begin
result := RealChar[Top];
Top := Top -1;
end;procedure Stack.Push(var s : Real);
begin
//if Not IsFull then
//begin
Top := Top + 1;
RealChar[Top] := s;
//end;
//else
//推出
end;
type
Stack = class
private
Top,MaxSize : integer;
RealChar : Array[1..30] of Real; public
constructor Creat ;
destructor Destory ;
function Pop : Real;
procedure Push(var s : Real) ;
function IsEmpty : Boolean;
function IsFull : Boolean;
end;constructor Stack.Creat ;
begin
Top := 0;
MaxSize := 30;
end;destructor Stack.Destory ;
begin
Top := 0;
end;function Stack.IsEmpty : Boolean;
begin
if Top = 0 then
result := True
else
result := False;
end;function Stack.IsFull : Boolean;
begin
if Top >= 30 then
result := True
else
result := False;
end;function Stack.Pop : Real;
begin
result := RealChar[Top];
Top := Top -1;
end;procedure Stack.Push(var s : Real);
begin
//if Not IsFull then
//begin
Top := Top + 1;
RealChar[Top] := s;
//end;
//else
//推出
end;
b:real;
begin
Stack1:=Stack.Creat;
b:=1.2;
Stack1.Push(b);
ShowMessage(FloatToStr(Stack1.RealChar[1]));
Stack1.Free;
end;