A scope or block scope is a visiblity and validiity construct of C and languages with similar syntax such as C++, Java, etc.

Names, e.g. variables, declared in a scope are usually only visible within the scope and nested scopes, not outside, i.e. not in the parent scope or sibling scopes.

Languages such as C and C++, which allow data on the stack, destroy such data when the variable's scope ends.

Qt Code:
  1. int main()
  2. {
  3. // inside scope of main()
  4. int a;
  5.  
  6. a = 3; // valid
  7.  
  8. {
  9. int b;
  10.  
  11. // inside a nested scope
  12. a = 4; // valid
  13. b= 4; // valid
  14. }
  15.  
  16. a = 5; // valid;
  17. b = 5; // will not compile, b only visible/valid in nested scope
  18. }
To copy to clipboard, switch view to plain text mode 

In C++, an object such as std::vector is destroyed (its destructor is invoked) when the scope it lives in ends.
Qt Code:
  1. int main()
  2. {
  3. vector<int> a;
  4.  
  5. {
  6. vector<int> b;
  7.  
  8. }// b is destroyed
  9.  
  10. }// a is destroyed
To copy to clipboard, switch view to plain text mode 

Cheers,
_