khoahoc.vietjack.com

Câu hỏi:

28/07/2025 107 Lưu

What is wrong in the following code? #include class Base { public: Base() {}; virtual ~Base() {}; }; class Derived : protected Base { public: virtual ~Derived() {}; }; int main() { Base *pb = new Derived(); return 0; }

A. There is nothing wrong

B. One cannot have a ‘Base’ pointer to ‘Derived’ since it is not derived publicly

C. One need a derived class pointer to point to a derived class

D. One required to code a constructor for Derived

Quảng cáo

Trả lời:

verified Giải bởi Vietjack

Chọn đáp án B

CÂU HỎI HOT CÙNG CHỦ ĐỀ

Lời giải

Chọn đáp án B

Lời giải

Bạn cần đăng ký gói VIP ( giá chỉ từ 250K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.

Nâng cấp VIP

Câu 5

A. The class must not have method

B. The class must have a constructor that takes no arguments

C. The class must have a function definition equal to zero

D. The class may only exist during the planning phase

Lời giải

Bạn cần đăng ký gói VIP ( giá chỉ từ 250K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.

Nâng cấp VIP

Câu 6

A. Have wine and cheese with that other friend

B. Allow that class to declare an instance of it in its list of private variables

C. Allow the other class (the one declared as friend) to access to the declaring class’s private variables

D. Allow the class declaring the other as a friend to access the declared class’s private variables

Lời giải

Bạn cần đăng ký gói VIP ( giá chỉ từ 250K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.

Nâng cấp VIP

Lời giải

Bạn cần đăng ký gói VIP ( giá chỉ từ 250K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.

Nâng cấp VIP