0

Here what's the meaning of cout<<::x

#include <iostream> using namespace std; void fun(); int x=1; int main() { fun(); return 0; } void fun(){ int x=2; { int x=3; cout<<::x; } } output is 1

15th Apr 2018, 9:15 AM
Khushboo Gupta
Khushboo Gupta - avatar
1 Answer
+ 6
:: is a scope resolution operator. ::x accesses the value of the global x, instead of the local x in the function.
15th Apr 2018, 9:17 AM
Alex
Alex - avatar