How to access a global variable within a local scope?

Viewed 32488

This is my code

#include <iostream>
using namespace std;
int x = 5;
int main()
{
    int x = 1;
    cout << "The variable x: " << x << endl;
}   

I get as output 1, but I would like to have 5, as in accessing the global x variable.

Is this possible?

1 Answers
Related