Computer Science, asked by ashwethalifecrazy, 10 months ago

What will be the output of this program?#include <iostream>using namespace std; class sample{ int x;} int main(){ sample obj; obj.x=100; cout<<"x="<<obj.x<<endl;}​

Answers

Answered by rekhay934
0

Answer:

include<iostream>

using namespace std;

int x = 10;

void fun()

{

int x = 2;

{

int x = 1;

cout << ::x << endl;

}

}

int main()

{

fun();

return 0;

}

Output: 10

If Scope Resolution Operator is placed before a variable name then the global variable is referenced. So if we remove the following line from the above program then it will fail in compilation.

int x = 10;

Explanation:

pls mark as branliest

Similar questions