(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?

```
#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.

Computer Science & Information Technology

You might also like to view...

________ represents a means of communicating the development status of a workbook, and is not a form of protection

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

A ____ model serves as the essential basis for effective management of a software operation.

A. standardized framework B. hybrid framework C. custom framework D. non-standard

Computer Science & Information Technology