Basic Pascal Tutorial/Chapter 5/Records/zh CN
English · Français · Български · 中文(中国) · 日本語
5E - 记录类型 (原作者: Tao Yue, 状态: 未更改)
记录类型允许你将多个数据类型组成一个数据类型。假设你想存储一个人的信息,它会包含姓名、年龄、城市、区域、国家、邮编等信息。
你可以这样来声明记录类型:
TYPE
??????????????? = record
?????????1 : ??????1;
...
?????????n : ??????n;
end;如:
type
InfoType = record
Name : string;
Age : integer;
City, State : String;
Zip : integer;
end;Name、Age、City、State和Zip这些标识符,被称为字段。通过变量名来使用这些字段:
???????????????.???????????????使用点(.)来分隔变量名和字段名。
定义记录类型变量:
VAR
???????????????:???????????????;在处理记录数据类型时,如果一个记录字段很多,你得一个一个的输入变量名,这样很繁琐。
你可以只使用字段标识符。像这样:
WITH ??????????????? DO
BEGIN
...
END;如:
with Info do
begin
Age := 18;
ZIP := 90210;
end;| 上一页 | 目录 | 下一页 |
From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 5/Records/zh CN", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.