The following conditions compile in Visual Studio C ++:
if(int x = 5) { std::cout << x; } 1
and
if(static int x = 5) { std::cout << x; } 2
On the other hand, the gnu compiler only compiles the first one. From testing, it seems that the scope of the variable is only in the if condition.
However, since Visual Studio compiles both versions, I was wondering if there are any differences?
source
share