Accessing anonymous namespaces?
Hi guys,
I have this chunk of code:
Code:
...
int x = 10; // global
void main() {
int x = 20; (line A)
{
int x = 30;
// How to read the value of x from the line A in this scope?
}
}
The question is in the code: How to read the value of x from the line A in this scope?
Code:
cout << x ; // gives 30;
cout<<::x; // give 10;
Thanks for any help :)
Kacper
Re: Accessing anonymous namespaces?
You can't. The local scope overrides the function scope.
Re: Accessing anonymous namespaces?
Hi,
Quote:
The local scope overrides the function scope.
I do know that. But are you 100% sure that the var from the function scope can't be accessed?
Thanks,
Kacper
Re: Accessing anonymous namespaces?