我定义了一个简单的类,mymsg,调用很正常。可以使用。但是关闭程序的时候,会出错,这是为什么?提示:exception eaccessviolation in module project1.exe at 0001b74e.access violation at address 00471b74e in module 'project1.exe'.read of address 64726f8c
=============================
调用如下:
var  msg1:mymsg;
begin
     msg1.Msg :='hello';
     showmessage(msg1.Msg)  ;end;
=============================
在unit2中定义的类如下:
unit Unit2;interface uses 
  Dialogs; type 
  MyMsg = class(TObject) 
  private 
    FMsg: string; 
    function Getmsg(): string;
    procedure Setmsg(Value: string);  protected 
  public 
    function NullMsg: Boolean; 
    procedure PrintMsg; 
    property Msg : string Read GetMsg Write SetMsg;
  published 
  end; implementation{ MyMsg } 
function mymsg.Getmsg():string;
begin
result:=fmsg;
end;procedure mymsg.Setmsg(Value:string);
begin
fmsg:=Value;
end;function MyMsg.NullMsg: Boolean; 
begin 
  Result := FMsg = ''; 
end; procedure MyMsg.PrintMsg; 
begin 
  if IsConsole then 
    Writeln(FMsg) 
  else 
    ShowMessage(FMsg); 
end; end.