This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Polymorphism can be acheived by two means: 1.Inheritance is-a relationship 2.Aggregation has-a relationship
Inheritance is achieved by extending the existing class using the extends clause and Aggregation is by declaring a object of a class as a member in another class.
I need some clarifications on when and where to use inheritance and aggregation.
Please provide me with some examples and explanations.
Originally posted by Prasath Thirumoorthy: ...Polymorphism can be acheived by two means: 1.Inheritance is-a relationship 2.Aggregation has-a relationship ...
Uh...
Originally posted by Prasath Thirumoorthy: ...I need some clarifications on when and where to use inheritance and aggregation...
In general, favor composition (has-a) over inheritance (is-a). If you have a need for polymorphism, then use inheritance. (But you're going to need to clarify exactly what polymorphism is before this makes sense.)
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org