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