Simran Dass wrote:
Cannot understand how the code in class B works. Why would we want to do this
Basically, you want to create a new class that IS-A a particular sub class, but you don't have the complete implementation. Or you have multiple possible implementations, of which the subclass implementation is not one of them.
Granted, it is not a common case, but it can happen.