Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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. 13 marks] (b) Given the C+ + declaration: class A 1 public: int x; protected: int y; 0; Which of the following would be rejected by the compiler? 1) class B: public A void f) xy: 2) class B f void f) t A a; a.x a.y; 3) class B: public A ; class C: public B f 0; 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 nstructor, correctly set access modifiers, and follow information hiding policy with respect to the variable int smarks so that all set/get methods 17 marks] are introduced if required. li. Assume that in the previous part, Markor has an abstract method defined [2 marks] [Total for Question 8: 14 marks] as part of the class. Explain what this means for the Marker00P class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started