The following code fails to compile stating \"A local variable named \'st\' cannot be declared in this scope because it would give a different meaning to \'st\', which is a
You're declaring a variable in a limited scope and trying to use it outside of that scope. The compiler assumes you don’t want access to it so you can declare a variable with the same name somewhere else in the file. Your trying to do the old C trick of assuming the variable will live immediately outside of the scope. For example this used to work in older versions of C/C++ but no longer does.
for (int i=0; i<10; i++)
{
cout <<”In the loop i is “<< i << endl;
}
cout << “outside of the loop i is “ << i << endl; //this only compiles with old C/C++ compilers.