Câu 59: CPP: C++ Certified Professional Programmer
Which changes introduced independently will allow the code to compile and display “one” “eight” “nine” “ten”? Choose all that apply.#include #include #include using namespace std;class A {int a;public:A(int a):a(a){}int getA() const { return a;}/* Insert Code Here 1 */};/* Insert Code Here 2 */int main(){int t[] ={ 3,…
Nội dung câu hỏi
Which changes introduced independently will allow the code to compile and display “one” “eight” “nine” “ten”? Choose all that apply.#include #include #include using namespace std;class A {int a;public:A(int a):a(a){}int getA() const { return a;}/* Insert Code Here 1 */};/* Insert Code Here 2 */int main(){int t[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 10 };string s[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight","ten"}; multimap m;/* Replace Code Here 3 */ for(int i=0; i (A(t[i]),s[i]));}m.erase(m.lower_bound(2),m.upper_bound(7));multimap ::iterator i=m.begin();/* Replace Code Here 4 */ for( ; i!= m.end(); i++) { cout second<<" ";}cout<<endl;return 0;}
Các lựa chọn
Đáp án được giữ gọn theo nhãn A, B, C, D trong phần bình chọn tương tác.
- A. operator int() const { return a;} inserted at Place 1 — đáp án hiện tại
- B. bool operator < (const A & b) const { return a<b.a;} inserted at Place 1 — đáp án hiện tại
- C. bool operator < (const A & b) const { return b.a<a;} inserted at Place 1
- D. struct R { bool operator ()(const A & a, const A & b) { return a.getA() m; replacong line marked 4 with multimap ::iterator i=m.begin(); — đáp án hiện tại
Cộng đồng
0 bình luận công khai. Tên thành viên được ẩn một phần.