請問 ppointer(Self)^ 與 pointer(self) 的差別 |
尚未結案
|
yirunner
一般會員 發表:11 回覆:8 積分:3 註冊:2002-09-17 發送簡訊給我 |
各位好: 在system unit 中 tobject 的classtype 實作: function TObject.ClassType: TClass;
begin
Pointer(Result) := PPointer(Self)^;
end; 小弟有個疑問:
為何要先強制轉型 self 成 ppointer type再 用 '^' 指向? 而
若寫成 pointer(self) 是否會有其他問題? 因為就語法來看這兩者是相同的, 所以我覺得 使用ppointer 搭配 '^'有其他意義 請各位有以教我 謝謝
|
mustapha.wang
資深會員 發表:89 回覆:409 積分:274 註冊:2002-03-13 發送簡訊給我 |
|
yirunner
一般會員 發表:11 回覆:8 積分:3 註冊:2002-09-17 發送簡訊給我 |
各位好: 我在Borland newsgroup 上發表同樣問題後, 終於有了回應如下: > In my thought the statement: "PPointer(self)^" is equal to
> "Pointer(self)", but there must be some reason for the source code. No, they are not: suppose we have a momery aadress AAAA which stores a value BBBB (both
are 4-byte data chunks) Pointer(AAAA) = AAAA
PPointer(AAAA)^ = BBBB i.e. PPointer(AAAA)^ gives the value stored in the given memory location
as a pointer. 以上是 Gert Kello 的回覆 可見ppointer(variable)^ 的目的是將變數所指向的值轉換成 pointer type 的用法 給各位參考 願此園地更加茁壯 謝謝
|
mustapha.wang
資深會員 發表:89 回覆:409 積分:274 註冊:2002-03-13 發送簡訊給我 |
|
nnn0918k
一般會員 發表:12 回覆:33 積分:14 註冊:2003-05-12 發送簡訊給我 |
Data: String;
DataPtr: Pointer;
Self: Cardinal;//PPointer DataPtr := @Data;
Self := Cardinal(@DataPtr); 只考慮內容的話..
DataPtr^ = Data;
Pointer(Self) = Self;
Pointer(Self)^ = DataPtr;
PPointer(Self) = Self;
PPointer(Self)^ = DataPtr;
PPointer(Self)^^ = Data; 火舞精靈 - 蘇
|
nnn0918k
一般會員 發表:12 回覆:33 積分:14 註冊:2003-05-12 發送簡訊給我 |
另一種表示法
Data = DataPtr^;
DataPtr = Self^;
Self = Pointer(Self) = PPointer(Self);
PPointer(Self) = Pointer(Self) = Self = @DataPtr = @@Data;
PPointer(Self)^ = Pointer(Self)^ = Self^ = DataPtr = @Data;
PPointer(Self)^^ = Pointer(Self)^^ = Self^^ = DataPtr^ = Data; 以上 火舞精靈 - 蘇
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |