對於記錄類型的迷惑,請教 |
答題得分者是:P.D.
|
qiziyh
一般會員 發表:2 回覆:7 積分:1 註冊:2008-09-29 發送簡訊給我 |
[code delphi] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TPeople = record Name : String; Age : Integer; Adress : String; PhoneNumber : String; end; type 。。 。。 。。 private { Private declarations } public { Public declarations } end; var Form1: TForm1; FileName : String; RWFileName : file of Tpeople; People : TPeople; implementation [/code] 請問上面的代碼中,我聲明了記錄類型Tpeople,在後面我把RWFileName聲明為自己定義的記錄類型文件,這個語法哪裡錯誤了嗎?為什麼在編譯的時候老是提示[DCC Error] Unit1.pas(16): E2155 Type 'TPeople' needs finalization - not allowed in file type呢?在網上查了很多資料,似乎都是這種寫法啊,為什麼我寫出來就編譯不過去呢?請原諒如此的無知問題,實在是找不到哪裡語法有錯誤,請教了 |
P.D.
版主 發表:603 回覆:4038 積分:3874 註冊:2006-10-31 發送簡訊給我 |
這是 Delphi Help 全文(引述..), 紅色的部份注意
或者使用 array[1..20] of Char 亦可 A file is an ordered set of elements of the same type. Standard I/O routines use the predefined TextFile or Text type, which represents a file containing characters organized into lines. For more information about file input and output, see Standard routines and I/O. To declare a file type, use the syntax type fileTypeName = file of type where fileTypeName is any valid identifier and type is a fixed-size type. Pointer types隝hether implicit or explicit铘re not allowed, so a file cannot contain dynamic arrays, long strings, classes, objects, pointers, variants, other files, or structured types that contain any of these. For example, type PhoneEntry = record FirstName, LastName: string[20]; PhoneNumber: string[15]; Listed: Boolean; end; PhoneList = file of PhoneEntry; declares a file type for recording names and telephone numbers. You can also use the file of ... construction directly in a variable declaration. For example, var List1: file of PhoneEntry; The word file by itself indicates an untyped file: var DataFile: file; For more information, see Untyped files. Files are not allowed in arrays or records. |
qiziyh
一般會員 發表:2 回覆:7 積分:1 註冊:2008-09-29 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |