Imagine you are developing an e-commerce system where different types of users (Admin, Buyer, and Seller) exist. Which inheritance model might be beneficial to maintain, expand, and utilize polymorphic behavior?
- Single Inheritance
- Multiple Inheritance
- Hierarchical Inheritance
- Hybrid Inheritance
Hierarchical inheritance is where a single class serves as a base class (superclass) for more than one derived class (subclass). In this scenario, the common attributes and methods of users can be part of the base class, while unique functionalities for Admin, Buyer, and Seller can be defined in their respective derived classes.
Loading...
Related Quiz
- What does the term “Diamond Problem” refer to in the context of C++ inheritance?
- How can a function indicate that it will not throw any exceptions?
- To find the first mismatching elements of two ranges in C++ STL, use the _______ algorithm.
- How does the logical AND (&&) operator behave when the first operand is false?
- How does C++ handle template instantiation when the same instantiation is required in multiple translation units?