Q2 We need to add fly behaviour for ducks. But we know that all the types of ducks cannot fly e.g Rubber duck cannot fly. If we add the fly behaviour to the parent class, what will be the problem in using inheritance now? What solution do you suggest for solving this problem? (Hint: Find out what is multiple inheritance, when and how do we use it) Q3 Implement the suggested solution in Q2. Q4 State any two problems with implementation in Q3, in terms of function's implementation and code reusability.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
oop in c++
Q2
We need to add fly behaviour for ducks.
But we know that all the types of ducks cannot fly e.g Rubber duck cannot fly.
If we add the fly behaviour to the parent class, what will be the problem in using inheritance now? What solution do you suggest for solving this problem? (Hint: Find out what is multiple inheritance, when and how do we use it)
Q3
Implement the suggested solution in Q2.
Q4
State any two problems with implementation in Q3, in terms of function's implementation and code reusability.


Trending now
This is a popular solution!
Step by step
Solved in 2 steps









