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.
You might also like to view...
Normal telephone cable is a type of ________
A) coaxial cable B) Ethernet cable C) twisted-pair cable D) fiber-optic cable
How can modifying power levels mitigate all-band interference problems?
What will be an ideal response?
What is the shortcut for duplicating a single element while using the
Move tool? What will be an ideal response?
The range variable is implicitly defined in the _____ clause and used to produce results in the ______ clause
a) where, put b) from, put c) from, select d) where, select e) in, foreach