Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous
Next: Control statements Up: C++ Summary Previous: Assignment statements

   
Blocks

   {
      int i;

      s1;
      s2;
   }

A block is a group of statements and optionally declarations enclosed in braces. The body of any function (see section 16) is a block. Blocks are also commonly used in control statements (see section 10).

Any variables declared within a block are strictly local to that block (and any enclosed block), and they are created each time the block is executed and destroyed when the block is exited (unless declared static).
© Cambridge University Engineering Dept
Information provided by Tim Love
2006-12-08