. You can add method to existing class even to that class whose source is not available to you. You can extend functionality of a class without subclassing. You can split implementation in multiple classes. While in Inheritance you subclass from parent class and extend its functionality.
In a way you can say that Category are better option than to use inheritance but, The reason inheritance is still exist is you can not add member variables in Category only methods but inheritance makes it possible.
0 comments:
Post a Comment