stay C/C++ Curly brackets indicate the scope of the variable ,

Local variables declared in braces begin with the scope arguments declaration , End after braces .

{ } It's a “ block ”, alone { } There is no change in the execution order , It's still sequential ,

example 1
void MyProcess(MyType input, MyType &output) {    MyType filter = input;    {
      MyType temp;       step1(filter,temp);    }    {       MyType temp;      
step2(filter,temp);    }    {       MyType temp;       step3(filter,temp);    }
   output = filter; }
The above program implements a simple pipeline / Filter structure :

               temp1    temp2   temp3

                  ↓            ↓             ↓ 

input --> step1 --> step2 --> step3 --> output

temp They're all temporary variables ,

If there is no brace constraint , Each temporary variable exists in the function scope , Then the probability of error increases greatly when the process is increased or decreased frequently .

In braces , Not only is the program clear to read , And it's not easy to make mistakes

example 2
{ int a=0; { int b=0; a=1; // correct , still a In the scope of } b=1; // error , Because I'm not here b Scope of ,b It's been destroyed }  

©2020 ioDraw All rights reserved
django Do not close CSRF middleware , Custom through CSRF Tested post request Understanding neural network machine translation in three minutes error: (-215:Assertion failed) Solution ETL tool kettle And datax Comparison test cases Oracle to Oracle Tiktok The matrix - Code rain ( Free delivery ) Interview questions : Handwritten list ( Include reverse linked list )-bash The Trojan horse , Have you ever met one ? Implementation and challenge of metadata service in data Lake PHP call shell command Notes on core principles of reverse engineering ( One )——Hello World-1