17 Polymorphism: Object Independence
To be most useful, objects need independence. Each should act as though it were a miniature computer that can send and respond to messages. As long as a new object type uses the appropriate interface, you should be able to plug it into existing software.
Literally, polymorphism means “many forms.” On the most basic level, it means the ability to implement the same operation multiple ways. Stated that way, it’s trivial. But the real point is this: without changing anything about the code that uses an object, you can substitute another object type and the program will still work.
Consider an analogy. Your word processor can successfully interact with any kind of printer you purchase. You can even, five years ...
Get C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.