Code blocks

C++, Java, and C# source code can be partitioned into code blocks, which may be nested inside other code blocks.

Two nested code blocks in this sample program are illustrated in Listing 4.

int main(){
  //Everything inside this matching pair of
  // curly braces constitutes a block of
  // code.

    { //Begin nested code block
      //Everything inside this matching
      // pair of curly braces constitutes a
      // nested block of code with no purpose 
      // other than to illustrate the nesting
      // of code blocks.

      //Display something on the screen
      cout << "Hello World\n";
    }//end nested code block

  return 0;
}//end main

Listing 4

(At this point, I will simply identify the code blocks.  I will explain the operational significance of code blocks in subsequent lessons.)

 

 

 

zz

zz

zz