Shishir Shivhare wrote:
Suppose if a class inherit another class.Will the child class will write the code of its parent class in it when it is converted at machine level or just link it.
There is only one copy of the code.
What is meaning of reuse of code.Is it copying of code?
If code is reused, i think it will increase coupling then why it is beneficial for object oriented design where low coupling is required?
Code reuse means
not copying code. It's when you write code once, and use that method, class, or library in multiple situations. And note that the main use of inheritance is
not code reuse. It is type implementation and specialization. Code reuse comes along as a natural side effect, when the parent class implements a method in a way that is appropriate for the child class as well. Again, though, we don't inherit from a class just to use its methods. If that's all we want--that is, if we're not making a specialized type of the parent class--then we should just use composition instead of inheritance.