I was reading a book and here, a program is given like this -
#include<fstream>
#include<string>
#include<vector>
int main()
{
string filename; // #1
cout << "Please enter name of file to open : ";
cin >> filename;
if(filename.empty())
{
cerr << "Something...";
}
ifstream inFile(filename.c_str()); // #2
if(!inFile)
{
cerr<< "Somthing...";
}
.
.
.
}
And the explanation paragraph says, that, the declaration statements exhibit locality of declaration, Which is explained like this
the declaration statements occur within the locality of the first use of defined objects.
I am very confused with that sentence and I am not able to understand what it actually means. I need an explanation with some example.