Inheritance and polymorphism
Object-Oriented Programming · Engineering
Study notes
Animal base class has speak(); Dog inherits and overrides speak() to bark, Cat to meow. A function makeSpeak(Animal a) calls a.speak(); passing Dog barks, passing Cat meows. The same interface, different behavior: polymorphism. Code reuse via inheritance; flexibility via overriding.