
上QQ阅读APP看书,第一时间看更新
Limiting variable scopes to if and switch statements
It is good style to limit the scope of variables as much as possible. Sometimes, however, one first needs to obtain some value, and only if it fits a certain condition, it can be processed further.
For this purpose, C++17 comes with if and switch statements with initializers.