25.11 — Printing inherited classes using operator<<
Consider the following program that makes use of a virtual function: #include <iostream> class Base { public: virtual void print() const { std::cout << “Base”; } }; class Derived : public Base { public: void print() const override { std::cout << “Derived”; } }; int main() { Derived d{}; Base& …