In the following program, how many times Base’s constructor will be called? #include using namespace std; class Base { int static i; public: Base() { cout << "Base's constructor"; }; }; class Sub1 : public virtual Base {}; class Sub2 : public Base {}; class Multi : public Sub1, public Sub2 {}; void main() { Multi m; system("pause"); }
A. 1
B. 2
C. 3
D. error
Câu hỏi trong đề: 700+ câu trắc nghiệm Ngôn ngữ lập trình C có đáp án !!
Quảng cáo
Trả lời:
Chọn đáp án B
Hot: 1000+ Đề thi cuối kì 1 file word cấu trúc mới 2025 Toán, Văn, Anh... lớp 1-12 (chỉ từ 60k). Tải ngay
CÂU HỎI HOT CÙNG CHỦ ĐỀ
Câu 1
A. i1=2 i2=2
B. i1=2 i2=3
C. i1=3 i2=2
D. Error
Lời giải
Chọn đáp án B
Câu 2
A. Information hiding
B. Inheritance
C. Redefinition
D. Overloading
Lời giải
Chọn đáp án B
Câu 3
A. 21,21
B. 20,21
C. 21,22
D. compile error
Lời giải
Bạn cần đăng ký gói VIP ( giá chỉ từ 199K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.
Câu 4
A. 100
B. 101
C. none
D. compile error
Lời giải
Bạn cần đăng ký gói VIP ( giá chỉ từ 199K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.
Câu 5
A. professor researcher teacher myprofessor
B. researcher professor teacher myprofessor
C. myprofessor teacher researcher professor
D. myprofessor researcher professor teacher
Lời giải
Bạn cần đăng ký gói VIP ( giá chỉ từ 199K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.
Câu 6
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
Lời giải
Bạn cần đăng ký gói VIP ( giá chỉ từ 199K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.