(Stroustrup, Design and Evolution of C++, page 411ff) In each of a) through i), which variable is a local variable? Which statement makes names from a namespace available? (What namespace?) Which are an error? (If so, why?) Which introduce a variable from a namespace? (What namespace?) Which hide a global variable?
What will be an ideal response?
```
#include
namespace X
{
int i, j , k;
}
int k;
void f1()
{
int i = 0;
using namespace X; //a)
i++; //b)
j++; //c)
k++; //d)
::k++; //e)
X::k++; //f)
using X::i; //g)
using X::k; //h)
using std::cout; //i)
}
```
Part a) makes names from namespace X available, part b) is the local
variable i. Part c) is X::j. Part d) is an error: ambiguous – is this X::k or
the global k? Part e) increments the global k. Part f) is explicitly X’s k. Part
g) is an error, i is declared twice. Part h) hides the global k. Part i) introduces
cout from namespace std.
You might also like to view...
How does Access let you know that a form is set as read-only?
A) The form fields will be grayed out. B) A notice will appear on the Status Bar while the form is open. C) A pop-up message will appear when the form is opened. D) No indication is given that a form is read-only.
System security begins with the installation of the _________
Fill in the blank(s) with the appropriate word(s).