Last Updated : 29 Oct, 2018

#include
using namespace std;
int x = 1;
void fun()
{
int x = 2;
{
int x = 3;
cout << ::x << endl; } } int main() { fun(); return 0; } [/sourcecode] (A) 1
(B) 2
(C) 3
(D) 0


Answer: (A)

Explanation: The value of ::x is 1.

The scope resolution operator when used with a variable name, always refers to global variable.

Quiz of this Question


Share your thoughts in the comments