Difference between delegation and inheritance in c++
Answers
Answered by
1
By using Inheritance , a subclass inherits all of the variables and all of the methods defined in the superclass. While by delegation you write another class with additional functionality that uses instances of the original class to provide the original functionality. In other words, when using inheritance the subclass is simply a subclass of the superclass with some additional functionality, while when using delegation, your delegating class contains a reference to an instance of the superclass and delegates the method calls to the superclass.
source: quora
source: quora
Similar questions
English,
8 months ago
English,
8 months ago
Business Studies,
8 months ago
Math,
1 year ago
Math,
1 year ago