unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TDateRec = record
Year: integer;
Month: (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec); //Month為1月到12月的英文字
Day: 1..31; //day為1~31的數值
end;
type
Name = record
FirstName: string;
LastName: string;
end;
type
Employee = record
EmName: Name; //Name為上面定義的結構包括FirstNmae及LastName
Addr: string;
Phone: string;
Salary: integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
test: Employee; //這兩個結構之後用到,可以得知Name的結構並不須要宣告
Dnow: TdateRec;
begin
test.EmName.FirstName:='123';
test.Addr :='456';
test.Phone:='333';
Dnow.year:=2006;
Dnow.Month:=Jun;
Dnow.Day :=30;
end;
end.
星期五, 9月 14, 2007
資料結構範例
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言