From the course: Nail Your C++ Interview
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Polymorphism in C++ - C++ Tutorial
From the course: Nail Your C++ Interview
Polymorphism in C++
- [Instructor] Allowing one item to be defined and used in multiple ways is the feature in object-oriented programming called polymorphism. Think of a door. Did you picture your home's front door or did you picture your office door or maybe you pictured your car door? A door simply means the mechanism that opens and closes to allow things in or out, yet the instances of doors can come in many forms. A car door wouldn't work if you put it on your house and a garage door sure wouldn't work in your office. If you are designing a home, you probably have a door class, then create multiple instances of unique doors, like a front door, garage door, and closet door. Think about other examples where this feature would apply. Some of my favorites are pies, robots, and people. This means we can create high-level objects that can be used over and over. The more code gets used, the more it's tested, and in the end, it becomes much more…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.