700+ câu trắc nghiệm Ngôn ngữ lập trình C có đáp án - Phần 20

What is wrong in the following code? #include using namespace std; class Base { public: virtual void Method() = 0 { n = 1; } private: int n; }; class D1 :Base {}; class D2 :public D1 { int i

2/25

What is wrong in the following code? #include using namespace std; class Base { public: virtual void Method() = 0 { n = 1; } private: int n; }; class D1 :Base {}; class D2 :public D1 { int i; void Method() { i = 2; } }; int main() { D2 test; return 0; }

There is no error

There is a syntax error in the declaration of “Method”

Class D2 does not have access to “Method”

Class D1 must define “Method”

Giải thích

Chọn đáp án A