const 在不同DELPHI版本下的问题 |
答題得分者是:Coffee
|
leonli80
一般會員 發表:29 回覆:27 積分:11 註冊:2006-08-01 發送簡訊給我 |
|
channel
尊榮會員 發表:67 回覆:707 積分:854 註冊:2002-05-02 發送簡訊給我 |
小弟用delphi5測試好像沒有問題
是不是delphi7比較嚴謹… 如果是在procedure test(const i: Integer = 1);基本上i是無法再修改的吧… ~小弟淺見,參考看看~ ===================引 用 文 章=================== <textarea class="delphi" rows="10" cols="60" name="code">const i : integer = 1; //================== 在程式中寫下面的語句 i := 3; </textarea> 如果在Delphi4中,可以編譯成功。 在Delphi7中報錯“Left side cannot be assigned to ” 如何解決?
------
~小弟淺見,參考看看~ |
Coffee
版主 發表:31 回覆:878 積分:561 註冊:2006-11-15 發送簡訊給我 |
check help yourself.
typed constants, unlike true constants, can hold values of array, record, procedural, and pointer types. Typed constants cannot occur in constant expressions. In the default {$J-} compiler state, typed constants can not have new values assigned to them; they are, in effect, read-only variables. However, if the {$J } compiler directive is in effect, typed constants can have new values assigned to them; they behave essentially like initialized variables. Declare a typed constant like this: const identifier: type = value where identifier is any valid identifier, type is any type except files and variants, and value is an expression of type type. For example, const Max: Integer = 100; In most cases, value must be a constant expression; but if type is an array, record, procedural, or pointer type, special rules apply.
------
不論是否我發的文,在能力範圍皆很樂意為大家回答問題。 為了補我的能力不足之處,以及讓答案可以被重複的使用,希望大家能儘量以公開的方式問問題。 在引述到我的文時自然會儘量替各位想辦法,謝謝大家! |
harpist
資深會員 發表:3 回覆:251 積分:430 註冊:2002-10-03 發送簡訊給我 |
|
Coffee
版主 發表:31 回覆:878 積分:561 註冊:2006-11-15 發送簡訊給我 |
|
h@visli
資深會員 發表:103 回覆:429 積分:431 註冊:2004-02-13 發送簡訊給我 |
------
------------------------ 博采眾家之長,奉獻綿薄之力 ------------------------ |
yufeiying
一般會員 發表:0 回覆:6 積分:1 註冊:2004-06-24 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |