C ++ keywords
| 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 |
The red part is unique to C ++, and the black part is a common part of C ++ and C.
Key Parts:
VolatileUsage:
1) Hardware registers of parallel Devices
2) Non-automatic variables that will be accessed in a terminal service subroutine
3) variables shared by several tasks in multi-threaded applications
In this thread, when reading a variable, in order to improve the access speed, the compiler sometimes first reads the variable to a register during optimization. When the variable value is obtained later, the value is taken directly from the register. When the value of a variable changes in the current thread, the new value of the variable is copied to the register at the same time to maintain consistency. However, when the value of a variable is changed due to other threads, the value of this register will not change accordingly, resulting in inconsistent values read by the application and the actual value of the variable.