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

1. During name resolution, nested namespaces behave like nested blocks.
2. A namespace is just a class with all the folderol stripped off.
3. Namespaces can be defined in pieces across several files.
4. A namespace grouping requires a semicolon after the closing curly brace.
5. The output from the following code is
“function”.
(The code will compile and run.)
```
#include
using namespace std;

namespace
{
char c_string[ 10 ] = "namespace";
}
void output()
{
char c_string[ 10 ] = "function";

cout << c_string << endl; // which c_string?

//other code
}
int main()
{
output();
}
```


1. True
When a name is used in a nested namespace, the surrounding namespace is searched for a declaration.
2. False
It does look like that, but a sort of opposite is closer to the truth. A class is very much like a specialized namespace. All operations supported for namespaces can be applied to classes with the same meaning.
3. True
4. False
A namespace definition is not like a class definition, in which an object of class type can be defined at the class definition. A namespace is not a type, so such a definition is not possible. There is no need for the semicolon. (At least this is not a reason for the semicolon. This writer knows of no other reason for a terminating semicolon for a class-like construct.)
5. True
As far as the local function is concerned, the unnamed namespace is a global definition of an array c_string. (Technically, we say c_string is local to the file, but non-local to the function.) The variable c_string defined in the

Computer Science & Information Technology

You might also like to view...

____ is marketed for profit by software publishers that require strict adherence to copyright rules.

A. Open source software B. Commercial software C. Shareware D. Freeware

Computer Science & Information Technology

If testing a program does not produce the expected results, the program contains an error, sometimes called a(n) ____.

A. bug B. variable C. spider D. code

Computer Science & Information Technology

Given an employee structure variable containing a name field, which of the following statements correctly references the name?

A. employee B. employee_name C. employee.name D. ptr->employee_name E. ptr->employee.name

Computer Science & Information Technology

Which standards organization is named for the Greek word for "equal"?

A. OSI B. ISO C. Cisco D. IEEE

Computer Science & Information Technology