我有整数和字符串的类,当我使用整数一切都很好,但当我使用字符串程序崩溃
//class
CatInfoType = class(TRemotable)
private
FcatId: Integer;
FcatName: string;
FcatParent: Integer;
FcatPosition: Integer;
FcatIsProductCatalogueEnabled: Integer;
published
property catId : Integer read FcatId write FcatId;
property catName : string read FcatName write FcatName;
property catParent : Integer read FcatParent write FcatParent;
property catPosition : Integer read FcatPosition write FcatPosition;
property catIsProductCatalogueEnabled: Integer
read FcatIsProductCatalogueEnabled
write FcatIsProductCatalogueEnabled;
end;
//program code
procedure TForm2.Button7Click(Sender: TObject);
var
rc: Integer;
k: CatInfoType;
l:String;
begin
k.catId:=4646;
k.catName:='777';//that crashing the program
end;
Run Code Online (Sandbox Code Playgroud)
不......不太好
k.catId:=4646; // <--- that crashing the program
k.catName:='777';
Run Code Online (Sandbox Code Playgroud)
您可能包含的错误消息就是这样的
在模块"MyProject.exe"中的地址xxxxxxxx处访问冲突.读取地址xxxxxxxx.
这k是一类CatInfoType- 你还没有实例化它.你想要的是:
k := CatInfoType.Create;
k.catId := 4646;
//... etc
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
144 次 |
| 最近记录: |