Special
rommi
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
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 · 1353 阅读 · 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 · 2225 阅读 · 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 · 2198 阅读 · 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 · 1515 阅读 · 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 · 1764 阅读 · 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 · 1531 阅读 · 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 · 1647 阅读 · 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 · 2463 阅读 · 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 · 1846 阅读 · 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 · 2724 阅读 · 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 · 1957 阅读 · 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 · 1678 阅读 · 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 · 2296 阅读 · 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 · 1959 阅读 · 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 · 1579 阅读 · 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 · 1480 阅读 · 0 评论 -
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 · 2117 阅读 · 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 · 2742 阅读 · 1 评论 -
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 · 1975 阅读 · 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 · 1463 阅读 · 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 · 1565 阅读 · 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 · 2142 阅读 · 0 评论 -
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 · 1992 阅读 · 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 · 4742 阅读 · 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 · 3135 阅读 · 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 · 2885 阅读 · 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 · 3456 阅读 · 1 评论 -
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 · 2202 阅读 · 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 · 2269 阅读 · 0 评论 -
(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 · 2202 阅读 · 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 · 1875 阅读 · 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 · 1547 阅读 · 0 评论 -
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 · 4698 阅读 · 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 · 2822 阅读 · 0 评论 -
Question 6: Which of the following are container adapters in the STL (Standard Template Library) in C++?
<br />A. list<br />B. map<br />C. stack<br />D. queue<br />E. deque<br /><br /><br />顺序性容器vector从后面快速的插入与删除,直接访问任何元素deque从前面或后面快速的插入与删除,直接访问任何元素list双链表,从任何地方快速插入与删除关联容器set快速查找,不允许重复值multiset快速查找,允许重复值map一对多映射,基于关键字快速查找,不允许重复值multimap一对多映射,基于关键字快速查找,允许重复值容器原创 2010-11-30 10:34:00 · 2320 阅读 · 0 评论 -
Question 9: Which of the following statements correctly describe the results of executing the code below in C++?
<br />#include <iostream>using namespace std;class ExBase{private: static int stat;public: static int GetStat(){ return stat; }};int ExBase::stat = 25;class ExDer1 : public ExBase{public: friend int Der1Fn(){ return Ex原创 2010-11-30 11:23:00 · 3613 阅读 · 1 评论 -
Question 12: In C++, which of the following is the best declaration for an overloaded operator[] to allow read-only access (and
<br />template<typename T><br />class MyArray<br />{<br /> //declaration goes here<br />};<br /> <br /> A. T& operator[](size_t i);<br /> B. const T& operator[](size_t i);<br /> C. const T& operator[](size_t i) const;<br /> D. T& operator[](原创 2010-11-30 11:55:00 · 1786 阅读 · 0 评论 -
Question 13: Which of the following declarations of function main are standard or standard conforming extensions? (Please note t
A. int main() B. void main(char* argv[], int argc) C. int main(int argc, char* argv[]) D. void main() E. int main(int argc, char* argv[], char* arge[])B原创 2010-11-30 11:55:00 · 1492 阅读 · 0 评论 -
(NOT CLEAR) Question 14: What is the correct declaration for a file stream insertion operator for a class my_stuff::my_class a
<br />#include <fstream>namespace my_stuff{ class my_class { public: int i; }; //Declaration goes here}//ns my_stuff<br /> A. std::ofstream& operator<<(std::ofstream& ofs, const my_class&);<br /> B. con原创 2010-11-30 11:58:00 · 1727 阅读 · 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 · 1877 阅读 · 0 评论
分享