type
TTest = class
private
g_s: String;
procedure setValue(s: String);
function getValue(): String;
public
property myValue: String read g_s write setValue;
end;implementation{ TTest }function TTest.getValue: String;
begin
Result := g_s;
end;procedure TTest.setValue(s: String);
begin
g_s := s;
end;
----------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
test: TTest;
begin
test.myValue := 'this is test value';
showMessage(test.myValue);
end;--------------------
E能够正常运行,但在程序退出时报错
Exception EAccessViolation in model Project1.exe at 000194DA
为什么呀? 谢谢
TTest = class
private
g_s: String;
procedure setValue(s: String);
function getValue(): String;
public
property myValue: String read g_s write setValue;
end;implementation{ TTest }function TTest.getValue: String;
begin
Result := g_s;
end;procedure TTest.setValue(s: String);
begin
g_s := s;
end;
----------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
test: TTest;
begin
test.myValue := 'this is test value';
showMessage(test.myValue);
end;--------------------
E能够正常运行,但在程序退出时报错
Exception EAccessViolation in model Project1.exe at 000194DA
为什么呀? 谢谢
test: TTest;
begin
test := TTest.Create;
test.myValue := 'this is test value';
var
test: TTest;
begin
test := TTest.Create;
test.myValue := 'this is test value';
showMessage(test.myValue);
end;