Question

When would you apply inheritance? When would you not? Provide examples of when inheritance is appropriate...

When would you apply inheritance? When would you not? Provide examples of when inheritance is appropriate and when it is not, discussing each.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Inheritance is applied when a programmer want to use the data members and functions  of existing class without writing new one.

Consider class shape having data member radius and classes rectangle, circle which have member functions area which return the area of corresponding figures.

So shape class can be made base class for circle as data members radius is needed for its area calculation but it is not made base class for rectangle as radius do not hold meaning with respect to rectangle area calculation

Add a comment
Know the answer?
Add Answer to:
When would you apply inheritance? When would you not? Provide examples of when inheritance is appropriate...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT