I have encountered the following code:
#include
using namespace std;
int i = 1;
int main(int argc,char ** argv)
{
int i = i;
cout&l
When you have two variable with same name, one is global and other is local. Then in this case local variable will get in use only in that particular scope. And global variable is unused.
Now, coming to your problem
#include
using namespace std;
int i = 1;//Global Variable decleration
int main(int argc,char ** argv)
{
int i = i; // Local to main
cout<
int i = i;
compiles without any error but when you run the program it will produce error because local i
has indeterminate value.