说明:下划线是我认为的答案,仅供参考。
【Q1】 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 number of objects allocated.
【Q2】 What is the order of destructor calls for an object of class Y inherited from class X that has an object of class A as data member of class Y in C++?
A. ~Y()
~X()
~A()
B. ~X()
~A()
~Y()
C. ~Y()
~A()
~X()
D. ~A()
~Y()
~X()
E. ~X()
~Y()
~A()
【Q3】 In C++, there is a standard global object wcin of type wistream. What is the template type of the wistream typedef?
A. std::basic_istream<wchar_t, char_traits<wchar_t> >
B. std::basic_istream<char, char_traits<char> >
C. std::istream<char, char_traits<char> >
D. std::istream<wchar_t, char_traits<wchar_t> >
E. std::wistream<char, char_traits<char> >
【Q4】 How can a C++ developer use the placement new syntax to make new allocate an object of class SomeClass at a particular memory address stored in a pointer type variable named pmem?
A. new SomeClass(pmem);
B. new(pmem) SomeClass;
C. new pmem SomeClass;
D. new SomeClass pmem;
E. new (pmem, SomeClass);
【Q5】 Under which of the following conditions will a C++ developer use polymorphism?
A. When there is a looping construct that uses a continue more than once
B. When there is a need for the code written today to call code written tomorrow
C. When there is a need to check for the type of an object to determine which function must be called
D. When there is a need to check the value of a variable to determine which of two or more functions to call
E. When there is a need to modify the existing interface of a class
【Q6】 Protected, or private, inheritance, as opposed to public inheritance, models which type of relationship in C++?
A. Has-a
B. Is-implemented-in-terms-of
C. Was-a
D. Can-only-have-one-of
E. Shares-a-relationship-with
【Q7】 Which of the following statements regarding functions' default arguments in C++ are correct?
A. Default arguments cannot be of pointer type.
B. Default arguments cannot be of a user-defined type.
C. Default arguments can never precede non-default arguments.
D. Default arguments exist in the global heap and not on the function's stack.
E. Default arguments are not considered for generating the function's signature.
【Q8】 In the declaration below, p is a pointer to an array of 5 int pointers:
int *(*p)[5];
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?
A. p = new int [3][5]*;
B. p = new int (*)[3][5];
C. p = new int [3]*[5];
D. p = new int *[3][5];
E. p = new int (*[3])[5];
【Q9】 Which of the following operators must be overloaded by function objects in the Standard Template Library?
A. operator +()
B. operator ++()
C. operator ==()
D. operator ()()
E. operator []()
【Q10】 A C++ developer wants to explicitly specialize the template function below for the char * type:
template <class T> void fn(T a){...}
Which of the following methods can the developer use to carry out this specialization?
A. void fn<char*>(char* a){...}
B. template <> void fn<char*>(char* a){...}
C. void fn<char*>(T a){...}
D. template <class T> void fn(char* a){...}
E. template <class T> void fn<char*>(T a){...}
No comments:
Post a Comment