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

Computer Science & Information Technology

You might also like to view...

The most commonly used type of relationship is the one-to-one relationship

Indicate whether the statement is true or false

Computer Science & Information Technology

A(n) ____________________ is an Internet-capable phone that usually also includes a calendar, an appointment book, an address book, a calculator, a notepad, games, and several other apps (programs).

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

Computer Science & Information Technology

You can use Cortana to find the weather for your location.? ____________________

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

If a host has made a DNS request, why does it not have to repeat the request the next time it needs the IP address for the same server?

What will be an ideal response?

Computer Science & Information Technology