
Special
rommi
这个作者很懒,什么都没留下…
展开
-
Question 41: Which of the following operators must be overloaded by function objects in the Standard Template Library?
<br /> A. operator +()<br /> B. operator ++()<br /> C. operator ==()<br /> D. operator ()()<br /> E. operator []()<br /><br /><br /><br />D function object原创 2010-12-03 10:42:00 · 1927 阅读 · 0 评论 -
Question 36: Which of the following statements regarding functions' default arguments in C++ are correct?
<br /> A. Default arguments cannot be of pointer type.<br /> B. Default arguments cannot be of a user-defined type.<br /> C. Default arguments can never precede non-default arguments.<br /> D. Default arguments exist in the global heap and not原创 2010-12-03 10:15:00 · 1892 阅读 · 0 评论 -
Question 48: In C++, which of the following statements accurately describe a base class destructor calling a virtual function ov
<br /> A. The base class destructor calls the virtual function override of the derived class through the vtable.<br /> B. The base class destructor cannot call the virtual function override of the derived class because the derived class portion of th原创 2010-12-03 10:57:00 · 2652 阅读 · 0 评论 -
(NOT CLEAR)Question 47: Which of the following statements correctly describe functions of the endl manipulator for the ostream o
<br /> A. It only flushes the standard output stream.<br /> B. It puts a newline character into the standard output stream and flushes the standard output stream.<br /> C. It puts an end-of-output character into the standard output stream.<br />原创 2010-12-03 10:55:00 · 1789 阅读 · 0 评论 -
Question 34: Under which of the following conditions will a C++ developer use polymorphism?
<br /> A. When there is a looping construct that uses a continue more than once<br /> B. When there is a need for the code written today to call code written tomorrow<br /> C. When there is a need to check for the type of an object to determine wh原创 2010-12-03 10:08:00 · 2375 阅读 · 0 评论 -
(NOT CLEAR)Question 44: What member function of std::fstream could a C++ developer invoke in order to change the target output f
<br /> A. setbuffer<br /> B. setfilebuf<br /> C. rdbuf<br /> D. filebuf<br /> E. streambuf原创 2010-12-03 10:48:00 · 1605 阅读 · 0 评论 -
Question 43: Which of the following define valid string constants in C++?
<br /> A. #define MESSAGE "Whoever said that you could run this program" &<br />"must not have known what you'd do."<br /> B. #define GREETING = "Hello!"<br /> C. #define MESSAGE = "This is a long message, but I know you have"<br />#define MESSAGE原创 2010-12-03 10:47:00 · 1474 阅读 · 0 评论 -
(NOT CLEAR)Question 32: In C++, there is a standard global object wcin of type wistream. What is the template type of the wistr
<br /> A. std::basic_istream<wchar_t, char_traits<wchar_t> ><br /> B. std::basic_istream<char, char_traits<char> ><br /> C. std::istream<char, char_traits<char> ><br /> D. std::istream<wchar_t, char_traits<wchar_t> ><br /> E. std::wistream<c原创 2010-12-03 09:58:00 · 1716 阅读 · 0 评论 -
Question 30: What is the order of destructor calls for an object of class Y inherited from class X that has an object of class A
<br />A. ~Y() ~X() ~A()<br />B. ~X() ~A() ~Y()<br />C. ~Y() ~A() ~X()<br />D. ~A() ~Y() ~X()<br />E. ~X() ~Y() ~A()<br /><br /><br />C<br /><br /><br />构造函数调用次序: 基类构造函数(按申明顺序) 派生类成员变量构造函数 派生类自己构造函数<br /><br />析构函数调用次序: 与基类完全相反原创 2010-12-02 18:13:00 · 1467 阅读 · 0 评论 -
Question 25: For the code snippet below, which of the following statements provide the correct order of constructor calls when o
<br />class Base{ public: Base(){cout << "In Base Ctor/n";} class Nest { public: Nest(){cout << "In Nest Ctor/n"; } }; };class Derive : public Base{ public: Derive(){cout << "In De原创 2010-12-01 14:40:00 · 2112 阅读 · 0 评论 -
Question 38: What is the output of the program below in C++?
<br />#include <iostream>using namespace std;class Object{public: Object() {} void Print() const { cout << "const" << endl; } void Print() { cout << "mutable" << endl; }};void pri原创 2010-12-03 10:33:00 · 1612 阅读 · 0 评论 -
Question 39: Which of the following are possible outputs of the C++ code below?
<br />#include <iostream>class TestPrint{public: void Print() { std::cout << "TestPrint" << std::endl; } void Print() const { std::cout << "const TestPrint" << std::endl; } void Print() vol原创 2010-12-03 10:38:00 · 1304 阅读 · 0 评论 -
Question 37: In C++, which of the following statements regarding the code below are valid?
<br />#include <iostream>class Outer{ int m_o; public: class Inner { int m_i; public: Inner(){} Inner(Outer m_outer, int x) { m_outer.m_o = x; } }; Outer(int y)原创 2010-12-03 10:25:00 · 2003 阅读 · 0 评论 -
Question 35: Protected, or private, inheritance, as opposed to public inheritance, models which type of relationship in C++?
<br /> A. Has-a<br /> B. Is-implemented-in-terms-of<br /> C. Was-a<br /> D. Can-only-have-one-of<br /> E. Shares-a-relationship-with<br /><br /><br />B原创 2010-12-03 10:09:00 · 1507 阅读 · 0 评论 -
Question 33: How can a C++ developer use the placement new syntax to make new allocate an object of class SomeClass at a particu
<br /> A. new SomeClass(pmem);<br /> B. new(pmem) SomeClass;<br /> C. new pmem SomeClass;<br /> D. new SomeClass pmem;<br /> E. new (pmem, SomeClass);<br /><br /><br />B原创 2010-12-03 10:01:00 · 1395 阅读 · 0 评论 -
Question 31: A C++ developer wants to handle a static_cast() operation for the class String shown below. Which of the following
<br />class String {<br />public:<br /> //...<br /> //declaration goes here<br />};<br /> <br /> A. char* operator();<br /> B. char* operator char*();<br /> C. String operator char*();<br /> D. operator char*();<br /> E. char* operator S原创 2010-12-03 09:57:00 · 1911 阅读 · 0 评论 -
Question 29: The C++ code below generates a compiler error. Which of the following solutions can be used to correctly access the
<br />class SomeClass{ public: int data; protected: class Nest { public: int nested; }; public: static Nest* createNest(){return new Nest;}};void use_someclass()原创 2010-12-02 17:59:00 · 2691 阅读 · 1 评论 -
Question 46: Which of the following statements describe correct methods of handling C++ exceptions?
<br /> <br /> A. Once an exception is thrown, the compiler unwinds the heap, freeing any memory dynamically allocated within the block from which the exception was thrown.<br /> B. In a hierarchy of exception classes, the order of handling exceptions原创 2010-12-03 10:55:00 · 2034 阅读 · 0 评论 -
(NOT CLEAR)Question 45: Which of the following options are returned by the typeid operator in C++?
<br /> A. A reference to a const std::type_info object<br /> B. A const std::type_info object<br /> C. A const reference to a const std::type_info object<br /> D. A reference to a std::type_info object<br /> E. A const reference to a std::ty原创 2010-12-03 10:52:00 · 1429 阅读 · 0 评论 -
Question 42: A C++ developer wants to explicitly specialize the template function below for the char * type:
template void fn(T a){...}Which of the following methods can the developer use to carry out this specialization? A. void fn(char* a){...} B. template void fn(char* a){...} C. void fn(T a){...} D. template void fn(char* a){...} E. template原创 2010-12-03 10:45:00 · 1526 阅读 · 0 评论 -
(NOT CLEAR)Question 40: In the declaration below, p is a pointer to an array of 5 int pointers:
<br />int *(*p)[5];<br /> <br />Which of the following statements can be used to allocate memory for the first dimension in order to make p an array of 3 arrays of 5 pointers to type int?<br /> <br /> A. p = new int [3][5]*;<br /> B. p = new int (*)[原创 2010-12-03 10:41:00 · 1879 阅读 · 0 评论 -
Question 28: Which of the following statements accurately describe the new[] operator in C++?
A. It calls the class default constructor for each element of the array. B. It calls the class copy constructor for each element of the array. C. It calls operator new[](size_t). D. It calls operator new[](size_t, int). E. It stores the num原创 2010-12-01 16:11:00 · 2153 阅读 · 0 评论 -
Question 27: Which of the following reasons describe why a destructor cannot throw an exception in C++?
A. It can invoke the terminate() handler. B. Since the object is being destroyed, it is illogical to throw an exception then. C. The C++ language does not permit it; a throw statement in a destructor will be caught as an error by the compiler.原创 2010-12-01 14:53:00 · 2223 阅读 · 0 评论 -
Question 26: Which of the following options describe the expected overhead for a class that has 5 virtual functions?
<br />A. Every object of the class holds the address of a structure holding the addresses of the 5 virtual functions.<br /> B. Every object of the class holds the addresses of the 5 virtual functions.<br /> C. Every object of the class holds the addr原创 2010-12-01 14:50:00 · 3502 阅读 · 1 评论 -
Question 4: Which of the following statements correctly describe the code below in C++?
#define language 437 //Line 1#if language #undef language //Line 2#else //Line 3#define language 850 //Line 4#ifdef language //Line 5 printf("%d", language); //Line 6#en原创 2010-11-30 10:24:00 · 4609 阅读 · 1 评论 -
Question 23: Which of the following C++ keywords are designed to speed up execution of a C++ function?
<br /> A. friend<br /> B. static<br /> C. extern<br /> D. inline<br /> E. member<br /><br /> <br /><br />D原创 2010-11-30 14:54:00 · 1501 阅读 · 0 评论 -
(NOT CLEAR)Question 22: Which of the following functions of the ifstream class can be used to determine the current position of
<br /> A. void tellg(pos_type&)<br /> B. pos_type tellg()<br /> C. pos_type tellp()<br /> D. void tellp(pos_type&)<br /> E. void seekg(pos_type&)原创 2010-11-30 14:53:00 · 1801 阅读 · 1 评论 -
(NOT CLEAR)Question 21: Which of the following statements provide a valid reason not to use RTTI for distributed (i.e. networked
A. RTTI does not have standardized run-time behavior. B. RTTI uses too much memory. C. RTTI is too slow. D. RTTI's performance is unpredictable/non-deterministic. E. RTTI frequently fails to function correctly at run-time.B C原创 2010-11-30 14:53:00 · 2135 阅读 · 0 评论 -
Question 20: Which allocator member function do standard containers use to acquire storage for their elements in C++?
A. std::allocator::allocate(size_t) B. std::allocator::malloc(int) C. std::allocator::make(size_t) D. std::allocator::new(size_t) E. std::allocator::acquire(size_t)原创 2010-11-30 14:35:00 · 2161 阅读 · 0 评论 -
Question 16: Which of the following methods can a developer use to override the default terminate() function in C++?
A. Write the terminate() function with two int arguments. B. Write the terminate() function with a runtime_error argument. C. Pass the address of the overriding function to the set_terminate() function. D. Write the terminate() function with one原创 2010-11-30 12:26:00 · 2134 阅读 · 0 评论 -
Question 11: Which of the following statements describe the result when standard new cannot allocate the requested storage in C+
<br />A. It throws a bad_alloc exception.<br />B. It returns null.<br />C. It returns silently with no effect on the expression.<br />D. It throws an insufficient_memory exception.<br />E. It logs an error message to the mem_err.log file.<br /><br /><br />原创 2010-11-30 11:44:00 · 3362 阅读 · 1 评论 -
Question 10: Given the following program snippet, what can we conclude about the use of dynamic_cast in C++?
#include #include //Someone else's code, e.g. libraryclass IGlyph{public: virtual ~IGlyph(){} virtual std::string Text()=0; virtual IIcon* Icon()=0; //...};class IWidgetSelector{public: virtual ~IWidgetSe原创 2010-11-30 11:29:00 · 2829 阅读 · 0 评论 -
Question 8: In which of the following scenarios is a Copy Constructor called or invoked?
<br /> A. When no conversion function exists for converting the class object to another class object<br /> B. When an existing object is assigned an object of its own class<br /> C. When a function receives as an argument, an object of the class,原创 2010-11-30 10:51:00 · 3051 阅读 · 1 评论 -
Question 5: Which of the following statements regarding the benefits of using template functions over preprocessor #define macro
<br />A. A preprocessor macro expansion cannot work when user-defined types are passed to it as arguments.<br />B. Since the preprocessor does the macro expansion and not the compiler, the build process takes a longer period of time.<br />C. While expandin原创 2010-11-30 10:28:00 · 2605 阅读 · 0 评论 -
Question 7: Which of the following correctly identify benefits of the getline() member function for cin over the extraction oper
A. The getline() function by default, accepts whitespace, and returns on seeing the /n character, whereas the extraction operator returns when it encounters any whitespace character. B. Delimiters indicating end of input can be specified to the getline(原创 2010-11-30 10:42:00 · 4653 阅读 · 0 评论 -
Question 24: Which of the following template declarations provide the correct syntax to write a template class
<br />template <class T> class Derived;<br /> <br />that has to inherit from another template class<br /> <br />template <class T> class Base;?<br /> <br /> A. template <class T, class Q> class Derived<Q> : public Base<T><br /> where Q can be used as原创 2010-12-01 14:31:00 · 1484 阅读 · 0 评论 -
Question 19: Which of the following are not pre-processor directives in C++?
<br /> A. #ifndef<br /> B. #ifdef<br /> C. #elif<br /> D. #define<br /> E. #extern<br /><br /> <br />E原创 2010-11-30 14:22:00 · 1330 阅读 · 0 评论 -
(NOT CLEAR)Question 18: In the given C++ code snippet, which of the following statements correctly identify how Mon of enum DOW
<br />void main()<br />{<br /> const int Mon = 1, Tue = 2;<br /> enum DOW{ Mon = 11, Tue = 12 };<br /> ...<br /> <br /> A. The variable var will have to be of type enum DOW, and then defined as:<br /> <br />var = Mon;<br /> B. Mon of enum DOW c原创 2010-11-30 14:12:00 · 1366 阅读 · 0 评论 -
Question 17: Which of the following identify const-correctness failures in the C++ program below?
templateclass MyArray{public: MyArray(); MyArray(MyArray& copy); MyArray& operator=(MyArray& copy); //...};class MyData{public: MyData(MyArray& x, MyArray& y); //... const MyArray& x(); const MyArray&原创 2010-11-30 13:37:00 · 1669 阅读 · 0 评论 -
Question 15: Which of the following statements describe the results of executing the code snippet below in C++?
int var = 1;void main(){ int i = i;} A. The i within main will have an undefined value. B. The compiler will allow this statement, but the linker will not be able to resolve the declaration of i. C. The i within main will have a value of 1.原创 2010-11-30 12:01:00 · 1829 阅读 · 0 评论