什么是匿名{}块用C语言风格的目的是什么? [英] What is the purpose of anonymous { } blocks in C style languages?
本文介绍了什么是匿名{}块用C语言风格的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是匿名{}用C语言风格的块(C,C ++,C#)
What is the purpose of anonymous { } blocks in C style languages (C, C++, C#)
示例 -
void function()
{
{
int i = 0;
i = i + 1;
}
{
int k = 0;
k = k + 1;
}
}
修改 - !感谢所有出色的答案
Edit - Thanks for all of the excellent answers!
推荐答案
它限制变量的作用域为块内的{}
It limits the scope of variables to the block inside the { }.
这篇关于什么是匿名{}块用C语言风格的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文