J
J. Campbell
In the following example, is there any way to directly access the
"outside" variable, j, from the "inside" scope (after the inside j has
been created)?
Thanks,
Joe
#include<iostream>
using namespace std;
int j = 100; // global j
int main(){
int j = 50; // "outside" j
{
//int j = j/2; // undefined value...both j's are the "inside" j
int j(j/2); // no prob..."inside" j is assigned to "outside" j
cout << " global j = " << ::j << endl
<< " inside j = " << j << endl
<< "outside j = ?\n"; //any way to access "outside" j
//in this scope?
}
system("pause");
return 0;
}
"outside" variable, j, from the "inside" scope (after the inside j has
been created)?
Thanks,
Joe
#include<iostream>
using namespace std;
int j = 100; // global j
int main(){
int j = 50; // "outside" j
{
//int j = j/2; // undefined value...both j's are the "inside" j
int j(j/2); // no prob..."inside" j is assigned to "outside" j
cout << " global j = " << ::j << endl
<< " inside j = " << j << endl
<< "outside j = ?\n"; //any way to access "outside" j
//in this scope?
}
system("pause");
return 0;
}