Modern C++ Learning(3)-Control Flow (Basics)
Control Flow (Basics)
Conditional Branching
if (statement; condition) { … } C++17
useful for limiting the scope of temporary variables
int i = 0; |
Switching: Value-Based Branching
switch (statement; variable) { … } C++17
useful for limiting the scope of temporary variables
int i = 0; |
Loop Iteration
Range-Based Loops C++11
for (variable : range) { ... } |
range = object with standard iterator interface, e.g., std::vector
std::vector<int> v {1,2,3,4,5}; |
References
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 王赵安的博客!
评论