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

1. In a particular file, the names from the global namespace and names from an unnamed namespace defined in the file are accesses the same way: by writing the name.
2. If I just write code, it is not in any namespace.
3. The scope of a using directive or using declaration is from its position in the block to the end of the program.
4. You can have a name spelled the same in two different namespaces with no conflict in your program.


1. True
To use either name, one just uses the name. The compiler knows the difference. However, if the unnamed namespace name and the global name are the same, use of that name will cause an ambiguity error. The compiler will not be able to distinguish them. There is no mechanism to use the unnamed namespace name, but the global name can be accessed by qualifying with the just the scope resolution operator, for example, ::name.
2. False
Every piece of code that is not explicitly put into a name space is in the global namespace, and could be addressed using the scope resolution operator, as in ::name.
3. False
Using directives and declarations have scope exactly like a local variable. The scope extends from the declaration to the end of the block in which the declaration occurs.
4. True
The namespace groups names together and provides an access method that allows the same name to be used in several namespaces without conflict.

Computer Science & Information Technology

You might also like to view...

Describe the eight base data types in SQL.

What will be an ideal response?

Computer Science & Information Technology

To copy an image, _____ the picture, then use the Copy and Paste options from the shortcut menu.

A. right-click B. left-click C. double-click D. drag and click

Computer Science & Information Technology

With respect to organizations, confidentiality means protecting __________ information about company finances, procedures, products, and research that competitors would find valuable.

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

Computer Science & Information Technology

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

1) for statements cannot be represented as while statements. 2) Only one control variable may be initialized, incremented or decremented in a for statement header. 3) Modifying the control variable of a for statement in the body can cause errors. 4) The initialization expression, condition and increment expression in a for statement’s header must be separated with commas.

Computer Science & Information Technology