0

I have just joined your website. I am attending B.Tech in Computer science and have completed upto inheritance in c++.
My first question here is: What is the relationship between inheritance and composition and why the two can be used in place of other.

3
Contributors
6
Replies
7
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

>What is the relationship between inheritance and composition
Inheritance is a special case of composition.

>why the two can be used in place of other
They solve the same problem and they're equally functional. If you're willing to suffer notational and structural inconveniences, inheritance can always be used in place of composition, and vice versa.

0

>> inheritance can always be used in place of composition, and vice versa.
Oh??? How can virtual functions be implenmented with composition?

0

>> inheritance can always be used in place of composition, and vice versa.
>Oh??? How can virtual functions be implenmented with composition?
You forgot to quote the first part of that sentence:

If you're willing to suffer notational and structural inconveniences, inheritance can always be used in place of composition, and vice versa.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.