Exam 11: Separate Compilation and Namespaces

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

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

(True/False)
4.8/5
(33)

A namespace is just a class with all the folderol stripped off.

(True/False)
5.0/5
(34)

The scope of a using directive or using declaration is from its position in the block to the end of the program.

(True/False)
4.9/5
(36)

You can use #define to define a name for a C++ variable.

(True/False)
4.7/5
(30)

You want to use only one name,funct1,from name space MyNamespace.The directive #include "MyNamespace" has been places at the top of the file.You will call this function a large number of times in a block.Which of the following will make only the name funct1 available only in that block (not outside the block)?

(Multiple Choice)
4.8/5
(44)

Namespaces can be defined in pieces across several files.

(True/False)
4.9/5
(30)

You can have a name spelled the same in two different namespaces with no conflict in your program.

(True/False)
4.9/5
(40)

The include statement,#include <file.h> looks in the system defined directory for the file,file.h.(Windows PC and Macintosh users sometimes use "folder" for what I call "directory". )

(True/False)
5.0/5
(35)

The output from the following code is "function". (The code will compile and run. ) #include <iostream> 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(); }

(True/False)
4.8/5
(45)

A namespace grouping requires a semicolon after the closing curly brace.

(True/False)
4.8/5
(40)

Use a namespace grouping to insert this declaration,void greeting();,in namespace Problem2.Then,in another,separate namespace grouping,add the definition of greeting()in namespace Problem2.

(Essay)
4.8/5
(39)

You can declare several names from a namespace in one declaration: #include <iostream> using std::cout,std::cin,std::endl;

(True/False)
4.8/5
(41)

Given the namespace groupings that contain class definitions: namespace Savitch { \quad class String \quad { \quad\quad public: \quad\quad\quad char* fetchString( ); \quad\quad\quad void storeString(char[]); \quad\quad private: \quad\quad\quad char str[ 100 ]; \quad\quad\quad int length; \quad }; } namespace Teague { \quad class String \quad { \quad\quad public: \quad\quad\quad char* fetchString( ); \quad\quad\quad void storeString(char[]); \quad\quad private: \quad\quad\quad char str[ 100 ]; \quad\quad\quad int length; \quad }; } Create an object of class String,s1,from namespace Savitch and an object,s2,of class String,s1,from namespace Teague.Use a member function to give to each object a C-string message that tells of which namespace the class is a member.

(Essay)
4.8/5
(36)

Suppose we have the following namespace: namespace A { void f(int); //... } using namespace A; // In the global namespace void g() { f('a');// calls A::f(int) } In the global namespace,the function g( )calls f('a').There is no problem here,f('a')is unambiguously A::f(int).Now suppose at some later time,the following namespace grouping and using directive is inserted prior to the call to function f. namespace B { void f(char); //... } using namespace B; For convenience,all these are listed again. namespace A { void f(int); //... } using namespace A; namespace B { void f(char); //... } using namespace B; // In the global namespace void g() { f('a'); } In g(),to what does the call,f('a')resolve? How could the code be modified so that the call still resolves to A::f(int)?

(Essay)
4.7/5
(41)

The include statement,#include "file.h" looks first in the system defined directory for file.h then,if the file is not found,it looks in the user's current directory.(Windows PC and Macintosh users sometimes use "folder" for what I call "directory". )

(True/False)
4.8/5
(37)
Showing 21 - 35 of 35
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)