C++關鍵字

[圖片來源:cppreference]

1、const/volatile

The const (and volatile) qualifier binds to the left. This means that any time you see const, it is being applied to the token to the left of it. There is one exception, however; if there's nothing to the left of the const, it binds to the right, instead. It's important to remember these rules.

Another blog about const

Another blog about volatile


2、explicit

You have a MyString(int size) class with a constructor that constructs a string of the given size. You have a function print(const MyString&), and you call it with print(3). You expect it to print "3", but it prints an empty string of length 3 instead.


3、virtual

http://www.stroustrup.com/bs_faq2.html


4、mutable

 A mutable member in Class can be modified in const member function.


5、override/final

Another blog




Working……  To be detailed.


發佈了130 篇原創文章 · 獲贊 13 · 訪問量 28萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章