CertyRush
Đang tải...
C CertyRush
Câu hỏi free preview

Câu 10: CPP: C++ Certified Professional Programmer

Which sentence is correct about the code below?#include #include #include using namespace std;class A {int a;public:A(int a) : a(a) {}int getA() const { return a; }void setA(int a) { this?>a = a; }/* Insert Code Here */};struct add10 { void operator()(A & a) { a.setA(a.getA() + 10); } };int main() {int t[] = { 10, 5,…

Nội dung câu hỏi

Which sentence is correct about the code below?#include #include #include using namespace std;class A {int a;public:A(int a) : a(a) {}int getA() const { return a; }void setA(int a) { this?>a = a; }/* Insert Code Here */};struct add10 { void operator()(A & a) { a.setA(a.getA() + 10); } };int main() {int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };vector v1(t, t + 10);for_each(v1.begin(), v1.end(), add10());vector ::iterator it = find(v1.begin(), v1.end(), A(7)); cout getA() << 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.

  1. A. it will compile and print 7
  2. B. it will not compile — đáp án hiện tại
  3. C. it will compile but the program result is unpredictable
  4. D. adding code:bool operator !=(const A & b) const {if (this?>a != b.a) { return true; } return false; }at Place 1 will allow the program to compile

Cộng đồng

0 bình luận công khai. Tên thành viên được ẩn một phần.

Chưa có bình luận. Mở giao diện tương tác để bắt đầu thảo luận.

Câu hỏi liền kề