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

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

24/25

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; }

There is nothing wrong

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

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

One required to code a constructor for Derived

Giải thích

Chọn đáp án B