Use references.
// Block A
int aa = 30;
auto& ref_aa = aa;
{
// Block B
int aa = 40;
{
// Block C
int aa = 50;
cout << "block C " << aa << endl;
cout << "block A " << ref_aa << endl;
cout << "global" << ::aa << endl;
}
cout << "block B " << aa << endl;
}
Of course, that's quite meaningless; if you can modify the code, then just change the variable names, or refactor it such that fewer blocks are needed (using more functions, for example).