Question: (a) What is inheritance in object oriented programming? Illustrate your answer with a C+ + example that clearly shows the benefits of this approach. [3

 (a) What is inheritance in object oriented programming? Illustrate your answer

(a) What is inheritance in object oriented programming? Illustrate your answer with a C+ + example that clearly shows the benefits of this approach. [3 marks] (b) Given the C++ declaration: class A public: protected: int y; int x; Which of the following would be rejected by the compiler? 1) class B: public A f void fO 1x- y;h 1; 2) class B [ void f() { A a; a.x= ay; } 1; class C: public B 1 j; 3) class B: public A1>; void fO 1x- y;h 4) None of the above [2 marks] (c) You are given a class Marker. You need to define a new class Marker00P that inherits from Marker and additionally has an attribute int *marks and a single public function with the signature void capMarks (int). i. Write the C++ declaration for Marker00P that clearly shows the inher itance from Marker. Make sure that you explicitly declare the default constructor, correctly set access modifiers, and follow information hiding policy with respect to the variable int *marks so that all set/get methods are introduced if required. [7 marks] ll. Assume that in the previous part, Marker has an abstract method defined as part of the class. Explain what this means for the Marker00P class? 2 marksl

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!