Computer Science, asked by abidaijaz6731, 1 year ago

Difference between delegation and inheritance in c++

Answers

Answered by Anonymous
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
Similar questions