wine習得知識小記

來源:互聯網
上載者:User

標籤:des   style   c   color   a   int   

1、

VS2008:

sizeof cout:56
sizeof cin:60
sizeof streamsize: 4
 VS2012
sizeof cout:80
sizeof cin:96
sizeof streamsize: 8

這樣就很明顯了,為了支援大的stream而故意引入streamsize的改變。


2、

以前初學C\C++用pow函數的時候也有點疑惑,為什麼參數int要轉化成double,以為是系統規定的,當時為了編譯能過就用了轉換了,也沒有看原始碼的想法。今天看了HongQian給出的資料才知道,原來是考慮到那麼幾個問題才用double的,而且還提高了複用,感覺設計得很好~(除了給人一點點confuse)

Let‘s count the ways the hypthetical int pow_int(int, int) function could fail.


Overflow 
Result undefined pow_int(0,0) 
Result can‘t be represented pow_int(2,-1) 
The function has at least 2 failure modes. Integers can‘t represent these values, the behaviour of the function in these cases would need to be defined by the standard - and programmers would need to be aware of how exactly the function handles these cases.


3、

花括弧其實是為了定義變數……
加上了花括弧的話,裡面的變數只在這個花括弧裡有用。
case 1:{int a;break;}
case 2:{int a;break;}
否則就得
case 1:int a;break;
case 2:int b;break;
值得注意的是,C85 裡是不允許在任意地方定義變數的,必須放在一個複合陳述式的起始部分。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.