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

Question 8 (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; 1; Which of the following would be rejected by the compiler? 1) class B: public A void f() { x = y; } t; 2) class B void f CA a; a.x - a.y; h t; class C: public B t; 3) class B public At; void f) (x - y; > 4) None of the above 2 marks] (c) You are given a class Marker. You need to define a new class Marker0OP 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] 11. 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 marks] Total for Question 8: 14 marks]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
