在程序中常见一个单独的大括号包着一段程序,因为在大括号内声明的局部变量在大括号结束时就结束,这样清晰有条理,省内存。eg:
void Myprocess (Mytype input,Mytype output){
Mytype filter=input;
{
Mytype temp;
step1(filter,temp);
}
{
Mytype temp;
step2(filter,temp);
}
output=filter;
}
这样把每一步的值都加在filter中,不至于频繁使用临时变量而出错