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.