精華區beta Programming 關於我們 聯絡資訊
※ 引述《StubbornLin (Victor)》之銘言: : 剛才有個人問我一個問題 : int x=12; x=x++ + ++x; cout<<x; : 答案是多少,我跟他說這個行為未定義 : 結果會隨著compiler的實作而改變 : 他說這是 研究所的考題...... : 研究所...............囧rz||| ISO/IEC 14882:2003 5. Expressions 4 Except where noted, the order of evaluation of operands of individual operators and subexpressions of individual expressions, and the order in which side effects take place, is unspecified. (53) Between the previous and next sequence point a scalar object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be accessed only to determine the value to be stored. The requirements of this paragraph shall be met for each allowable ordering of the subexpressions of a full expression; otherwise the behavior is undefined. [Example: i = v[i++]; // the behavior is unspecified i = 7, i++, i++; // i becomes 9 i = ++i + 1; // the behavior is unspecified i = i + 1; // the value of i is incremented --end example] (啊, 這算騙銀幣嗎? 我居然又來抄寫規格書了. =_=) 其實我還蠻想知道到底是哪間學校哪個系所考出這種題目, 這樣以後才知道哪些人說的話該保留幾分 ... (爆) http://0rz.tw/602p0 [tenlong.com.tw] 前天去天瓏的時候看到這東西還有貨 ... 送禮自用兩相宜啊! 強烈支持你敗一本, 上面貼著考題, 貼一張便利貼畫個箭頭指向那個條款 然後寄到他們辦公室去 XDDDD 話說 Wiley 也有出這本 http://0rz.tw/992sL [tenlong.com.tw] -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.126.44.151