Exam 11: Separate Compilation and Namespaces
Exam 1: C++ Basics37 Questions
Exam 2: Flow of Control33 Questions
Exam 3: Function Basics30 Questions
Exam 4: Parameters and Overloading31 Questions
Exam 5: Arrays32 Questions
Exam 6: Structures and Classes37 Questions
Exam 7: Constructors and Other Tools32 Questions
Exam 8: Operator Overloading,friends,and References31 Questions
Exam 9: Strings37 Questions
Exam 10: Pointers and Dynamic Arrays29 Questions
Exam 11: Separate Compilation and Namespaces35 Questions
Exam 12: Streams and File IO43 Questions
Exam 13: Recursion40 Questions
Exam 14: Inheritance30 Questions
Exam 15: Polymorphism and Virtual Functions34 Questions
Exam 16: Templates27 Questions
Exam 17: Linked Data Structures30 Questions
Exam 18: Exception Handling29 Questions
Exam 19: Standard Template Library46 Questions
Exam 20: Patterns and Uml22 Questions
Select questions type
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)
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 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)
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
{
class String
{
public:
char* fetchString( );
void storeString(char[]);
private:
char str[ 100 ];
int length;
};
}
namespace Teague
{
class String
{
public:
char* fetchString( );
void storeString(char[]);
private:
char str[ 100 ];
int length;
};
}
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
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)