I need the following two questions answered, please answer in paragraph form in
ID: 3553157 • Letter: I
Question
I need the following two questions answered, please answer in paragraph form in full detail.
1. Without considering the access attributes, list and describe which base class members may not be inherited by a derived class and provide a rationale for why this is?
2.Write and explain the definition composition and how it is useful in writing object-oriented programming. Also, explain how it is different from inheritance and how both inheritance and composition are useful in developing object-oriented programs
Explanation / Answer
1.
Constructors of base class are inherited in derived class, but derived class can only access/call it through its own constructor using base keyword and this constructor will not be available to outside world while creating instance of derived class. Hence, such base class members may not be inherited by a derived class.
2.
Composition reuses existing code to make up a new class.
For instance, class Record might use class Address , class Phone, class Name in its definition. However, Record does not extend any of those classes in the sense of functionality. It is more of like grouping together items. A mixture of inheritance and composition are very useful tools. Using one over the other should be done intuitively.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.