W
w5w
Unregistered / Unconfirmed
GUEST, unregistred user!
这是在深度历险中下载的一个计算圆周率Pi的程序,
在D5下编译能通过,但运行出错。部分原码:
//类的定义
unit arctan;
interface
uses
Forms, SysUtils;
const
// If you want you can set these back to 9, 10 and 1 to see the performance
// with only one digit per array entry.
MaxValue = 99;
LessValue = 100;
MinPlaces = 2;
type
TByte = array[1 .. ((MaxInt div sizeof(Byte)) - 1)] of Byte;
PTByte = ^TByte;
TCalculatePi = class
precision: Integer;
vm, vn: PTByte;
private
procedure SetUp(Divisor: Integer);
procedure Add;
procedure Subtract;
procedure Multiply(Multiplier: Integer);
procedure Divide(Divisor: Integer);
procedure WriteSource(FileName: string
Divisor, Iterations: Integer);
procedure ReadSource(FileName: string);
public
constructor Create(SetPrecision: Integer);
destructor Destroy;
procedure ArcTan(Divisor: Integer);
procedure Sum;
end;
implementation
uses pidata;
constructor TCalculatePi.Create(SetPrecision: Integer);
begin
PiDataModule.start_position:= 1;
precision:= SetPrecision;
GetMem(vm, Precision + 1);
GetMem(vn, Precision + 1);
end;
end.
//该段在另一个unit中
implementation
uses pidata, arctan;
procedure TPiForm.OkBitBtnClick(Sender: TObject);
var
calculate_pi: TCalculatePi;
begin
calculate_pi.Create(PI_LIMIT);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//执行这个构造函数就出错,错误信息为:"Access violation at address 99EB700A"
end;
请帮我看看问题出在什么地方?
程序的完整代码 <a href="http://vcl.vclxx.com/DELPHI/D32SAMPL/PI.ZIP">在这里</a>
运行成功别忘了通知我。
在D5下编译能通过,但运行出错。部分原码:
//类的定义
unit arctan;
interface
uses
Forms, SysUtils;
const
// If you want you can set these back to 9, 10 and 1 to see the performance
// with only one digit per array entry.
MaxValue = 99;
LessValue = 100;
MinPlaces = 2;
type
TByte = array[1 .. ((MaxInt div sizeof(Byte)) - 1)] of Byte;
PTByte = ^TByte;
TCalculatePi = class
precision: Integer;
vm, vn: PTByte;
private
procedure SetUp(Divisor: Integer);
procedure Add;
procedure Subtract;
procedure Multiply(Multiplier: Integer);
procedure Divide(Divisor: Integer);
procedure WriteSource(FileName: string
Divisor, Iterations: Integer);
procedure ReadSource(FileName: string);
public
constructor Create(SetPrecision: Integer);
destructor Destroy;
procedure ArcTan(Divisor: Integer);
procedure Sum;
end;
implementation
uses pidata;
constructor TCalculatePi.Create(SetPrecision: Integer);
begin
PiDataModule.start_position:= 1;
precision:= SetPrecision;
GetMem(vm, Precision + 1);
GetMem(vn, Precision + 1);
end;
end.
//该段在另一个unit中
implementation
uses pidata, arctan;
procedure TPiForm.OkBitBtnClick(Sender: TObject);
var
calculate_pi: TCalculatePi;
begin
calculate_pi.Create(PI_LIMIT);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//执行这个构造函数就出错,错误信息为:"Access violation at address 99EB700A"
end;
请帮我看看问题出在什么地方?
程序的完整代码 <a href="http://vcl.vclxx.com/DELPHI/D32SAMPL/PI.ZIP">在这里</a>
运行成功别忘了通知我。