1

I came across a line of code that is quite confusing to me. I tried searching but wasn't sure what to even search for.

The line is as follows:

 int i = ++::i;

I am lost to whether this line evaluates to:

 int i+= i ;

Any help would be appreciated

1 Answers1

3

In

int i = ++::i;

the :: is there to tell the compiler use the i from the global scope. Without it the compiler is going to use the i you just declared which is undefined behavior. For more on that see Using newly declared variable in initialization (int x = x+1)?

Community
  • 1
  • 1
NathanOliver
  • 171,901
  • 28
  • 288
  • 402