Skip to content

Instantly share code, notes, and snippets.

@tuxmartin
Last active February 25, 2016 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxmartin/1500a6673d7bbd949eba to your computer and use it in GitHub Desktop.
Save tuxmartin/1500a6673d7bbd949eba to your computer and use it in GitHub Desktop.
C++ - Scope with Brackets
#include <iostream>
using namespace std;
int main(void)
{
cout << "Scope with Brackets" << endl;
{
int i = 111;
cout << "1. i=" << i << endl;
}
{
int i = 222;
cout << "2. i=" << i << endl;
}
return 0;
}
/*
$ g++ -o scope_with_brackets scope_with_brackets.cpp
$ ./scope_with_brackets
Scope with Brackets
1. i=111
2. i=222
$
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment