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

1. You can use the static qualifier with a global function, class or variable to get the same effect as an unnamed namespace.

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

1. False
Explanation: This might work for a time, but for some future version of your C++ compiler, this will stop working. This use of the keyword static in C++ is being phased out. It is being replaced by unnamed namespaces. Some future version of the C++ compiler will give an error when compiling such code. (Programmers say, “Some later version of the compiler will break your code.”.)
2. True
Explanation: 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.

Computer Science & Information Technology

You might also like to view...

Which one of the following is the attempt at fraudulently obtaining private information through e-mail?

A. Pretexting B. Diversion theft C. Phishing D. Baiting

Computer Science & Information Technology

If the value being searched for by a recursive binary search algorithm is in the array, which of the following is true?

a) the algorithm cannot return a nonpositive number b) the algorithm cannot return a nonnegative number c) the algorithm cannot return a zero d) the algorithm cannot return a negative number

Computer Science & Information Technology