Guided Notes
Inheritance & Polymorphism
Base and derived classes, protected members, virtual functions and override, abstract classes, and polymorphism through base pointers.
Inheritance
Slide 1 / 5A derived class reuses and extends a base class:
class Vehicle { public: void honk() const { std::cout << "Beep!\n"; } protected: std::string brand_ = "Generic"; };
class Car : public Vehicle { public: void describe() const { std::cout << brand_ << " car\n"; } };
Car c; c.honk(); c.describe();
Inheritance models an "is-a" relationship: a Car is a Vehicle.
