1
클래스에 변수를 호출 할 때 : BugFixing.dpr :파스칼 액세스 위반이 나에게이 오류지고 나는 파스칼에 매우 간단한 코드를 만든
Project BugFixing.exe raised exception class EAccessViolation with message 'Access violation at address 0040F1EE in module 'BugFixing.exe'. Write of address 00000004'.
이 프로그램은이 개 모듈로 구성을
program BugFixing;
{$APPTYPE CONSOLE}
uses
SysUtils, uLinearProgrammingMainLogic in 'uLinearProgrammingMainLogic.pas', math;
var
MinOrMax : integer ;
Question : TQuestion ;
begin
try
Randomize ;
MinOrMax := RandomRange(0,2) ;
Question.SetMaximiseQuestion(MinOrMax);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
그리고 uLinearProgrammingMainLogic.pas :
unit uLinearProgrammingMainLogic;
interface
uses sysUtils, math ;
type
TQuestion = class
private
MaximiseQuestion : boolean ;
public
procedure SetMaximiseQuestion (MinOrMax : integer) ;
end;
implementation
procedure TQuestion.SetMaximiseQuestion(MinOrMax : integer);
begin
if MinOrMax = 0 then
MaximiseQuestion := true
else
MaximiseQuestion := false ;
end;
end.
사람이 특급 수 있다면 왜 이것이 액세스 위반을 일으키는 지 내게 알려주세요. 미리 감사드립니다. :)
"생성"이라는 생성자를 추가하고 MaximiseQuestion ,하지만 그 절차를 사용하는 경우와 같은 오류가 발생하는 것 같습니다. 당신의 충고를 잘못 이해합니까? –
델파이 매뉴얼이나 도움말에서 구문을 찾으십시오. instancevariable : = tclasstype.create는 instancevariable.create가 아닙니다. –
고마워요! 이것은 잘 작동하는 것 같습니다. –