請問一下~~關於type |
尚未結案
|
cappu_cc
一般會員 發表:2 回覆:3 積分:1 註冊:2004-01-04 發送簡訊給我 |
|
azurecloud
中階會員 發表:52 回覆:108 積分:92 註冊:2003-09-04 發送簡訊給我 |
Hi, cappu_cc 您好:
type 是用來做宣告沒錯:A type declaration specifies an identifier that denotes a type. The syntax for a type declaration is
type newTypeName = type
where newTypeName is a valid identifier. For example, given the type declaration type TMyString = string; you can make the variable declaration var S: TMyString; 這段是 Delphi 的 Help 中對 record 常數的解釋
To declare a record constant, specify the value of each fieldas fieldName: value, with the field assignments separated by semicolonsin 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. 而 Byte 是 0..255 的整數 type card=record // card 是一個 record 型態的常數
paishe:byte; // 第一個 field 名字是 paishe 型態是 byte 值域是 0~255
paishu:byte; // 第二個 field 名字是 paishu 型態是 byte 值域是 0~255
end;
以上是我的解讀,希望幫的上忙。 ========================
我要努力向上======================== |
nancy
一般會員 發表:8 回覆:19 積分:10 註冊:2002-07-11 發送簡訊給我 |
|
cappu_cc
一般會員 發表:2 回覆:3 積分:1 註冊:2004-01-04 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |