C++中大括号

来源:互联网 发布:linux 固定ip配置 编辑:程序博客网 时间:2024/06/10 04:23

在程序中常见一个单独的大括号包着一段程序,因为在大括号内声明的局部变量在大括号结束时就结束,这样清晰有条理,省内存。eg:

void Myprocess (Mytype input,Mytype output){Mytype filter=input;{Mytype temp;step1(filter,temp);}{Mytype temp;step2(filter,temp);}output=filter;}


这样把每一步的值都加在filter中,不至于频繁使用临时变量而出错

0 0
原创粉丝点击