Question

The following C++ code has a compilation error. How can you correct it to properly use the abstract base class `Printer`? #include class Printer { public:     virtual void print() = 0; }; class LaserPrinter : public Printer { public:     void print() {         std::cout

A The code is already correct; there is no error.
B Change `virtual void print() = 0;` to `void print() {};`.
C Remove the `override` keyword from `LaserPrinter::print()`.
D Make `LaserPrinter` an abstract class.
E Change `Printer* p = new LaserPrinter();` to `LaserPrinter* p = new LaserPrinter();`.
Practice Next

Hey! Ask a query