program Project2_9;
{$apptype console}
{$R *.res}
Type
Pstu=^student;
student = RECORD
name : string[8];
number : 1..100;
sex : (female,male);
age : integer;
End;
Var
list,pcopy : Pstu;
ss:string;
Begin
new(list);
list^.name := 'wang';
list^.number:= 15;
list^.Sex := female;
list^.age := 19;
pcopy :=list; (* 这里为什么要把list赋给pcopy,直接用list做如下的操作,有什么不妥? *)
if pcopy^.sex=male then ss:='male' (* 这个ss从哪冒出来的? *)
else if pcopy^.sex=female then ss:='female';
writeln('name:',pcopy^.name,' number:',pcopy^.number,' sex:',ss,' age:',pcopy^.age); (* 这里为什么要用'sex:',ss, 而不用用'sex:',pcopy^.sex, ? *)
readln;
Dispose(list);
end.
2、ss在变量里声明为string类型,你可能没看到
3、' sex:'是字符,不是变量,所以不用pcopy^.sex完毕
pcopy是完全没必要的。
sex : (female,male);这里的sex为枚举(female,male)类型.
所以当sex为female时,pcopy^.sex 为整型的0