记录数组怎么初始化?在线等候! (50分)

  • 主题发起人 主题发起人 hthugm
  • 开始时间 开始时间
H

hthugm

Unregistered / Unconfirmed
GUEST, unregistred user!
type
arrayRecord=record
age:integer;
name:string;
end;
var
x:array[0..1] of arrayRecord=((1,'张三'),(2,'王五'))
好象不能这么初始化,希望高手指教!!
 
写一个过程如:
procedure iniMyArray;
begin
x[0].age := 1;
x[0].name := '张三';
x[1].age := 2;
x[1].name := '王五';
....
end;
 
哪还要你说。
希望高手继续指教
 
还是好好看一下delphi的帮助
To declare a record constant, specify the value of each field梐s fieldName: value, with the field assignments separated by semicolons梚n parentheses at the end of the declaration. The values must be represented by constant expressions. The fields must be listed in the order in which they appear in the record type declaration, and the tag field, if there is one, must have a value specified;
if the record has a variant part, only the variant selected by the tag field can be assigned values.
Examples:
type
TPoint = record
X, Y: Single;
end;
TVector = array[0..1] of TPoint;
TMonth = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec);
TDate = record
D: 1..31;
M: TMonth;
Y: 1900..1999;
end;
const
Origin: TPoint = (X: 0.0;
Y: 0.0);
Line: TVector = ((X: -3.1;
Y: 1.5), (X: 5.8;
Y: 3.0));
SomeDay: TDate = (D: 2;
M: Dec;
Y: 1960);
Record constants cannot contain file-type values at any level.
 
没见你的那种方式来初始化记录(数组应该这样可以,但是记录……):
x:array[0..1] of arrayRecord=((1,'张三'),(2,'王五'))
(1,'张三') 怎么对应到记录的字段上?
你是想要什么初始化方法啊?偷懒?
 
记录也是连续的内存空间
 
接受答案了.
 
后退
顶部