C++ | Misc C++ | Question 2
#include<iostream>
using namespace std;
int x = 1;
void fun()
{
int x = 2;
{
int x = 3;
cout << ::x << endl;
}
}
int main()
{
fun();
return 0;
}
|
(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
Last Updated :
29 Oct, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...