C++關鍵字

來源:互聯網
上載者:User
C++關鍵字
asm double new switch
auto else operator template
break enum private this
case extern protected throw
catch float public try
char for return typedef
class friend register union
const goto short unsigned
continue if signed virtual
default inline sizeof void
delete int static volatile
do long struct while

紅色的部分為C++專屬的,黑色的部分是C++和C語言共有部分。

關鍵區段說明:

Volatile 用處

1)平行裝置的硬體寄存器

2)一個終端服務子程式中會訪問到的非自動變數

3)多線程應用中的被幾個任務共用的變數

 在本次線程內,當讀取一個變數時,為提高存取速度,編譯器最佳化時有時會先把變數讀取到一個寄存器中。以後再取變數值時,就直接從寄存器中取值。當變數值在本線程裡改變時,會同時把變數的新值copy到該寄存器中,以便保持一致。但是當變數在因別的線程等而改變了值,該寄存器的值不會相應改變,從而造成應用程式讀取的值和實際的變數值不一致。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.