Having the following program, is it possible to access the value of x
global, that is, the one that is outside the main()
(in this case 10)?
#include<iostream>
using namespace std;
int x = 10;
int main() {
int x = 2;
cout << "\nlocal Variable x = " << x;
return 0;
}
In C++, you can use the scope resolution operator:
In C, it is something more far- fetched :
An indispensable condition in C is that said variable cannot be declared as
static
: