線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:915
推到 Plurk!
推到 Facebook!

請問一下~~關於type

尚未結案
cappu_cc
一般會員


發表:2
回覆:3
積分:1
註冊:2004-01-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-01-04 12:00:22 IP:211.76.xxx.xxx 未訂閱
請問一下delphi最上面的type 主要的功能是什麼呢    如果是宣告的話那 type card=record        paishe:byte;        paishu:byte;      end; 是什麼意思咧~~    拜託各位朋友~~幫我解答一下我的疑問~~感激不盡
azurecloud
中階會員


發表:52
回覆:108
積分:92
註冊:2003-09-04

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-01-04 18:51:45 IP:163.13.xxx.xxx 未訂閱
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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-01-07 17:29:51 IP:61.218.xxx.xxx 未訂閱
Type是用於宣告型態,你舉的例子中就是在宣告card是一個record的型態, record類似資料庫的表格,可以解釋為card表格中包含了paishe與paishu 二個欄位,其型態都是byte
cappu_cc
一般會員


發表:2
回覆:3
積分:1
註冊:2004-01-04

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-01-09 16:39:22 IP:211.76.xxx.xxx 未訂閱
喔~~謝謝你們~~幫了我一個大忙~~感激不盡
系統時間:2024-06-28 22:54:50
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!