Question: a. Explain the concept of polymorphism and inheritance. How do they relate to each other? (6 marks) b. Consider Program C-3. 1 // Program C-3

 a. Explain the concept of polymorphism and inheritance. How do they
relate to each other? (6 marks) b. Consider Program C-3. 1 //

a. Explain the concept of polymorphism and inheritance. How do they relate to each other? (6 marks) b. Consider Program C-3. 1 // Program C-3 2 #include 4 using namespace std; 6 int menu () { int choice; 8 cout "; 12 13 cin >> choice; 14 cout 2) throw 2; 18 19 return choice; 20 1 22 23 int main() { 24 try 25 int choice = menu(); 26 27 28 if (choice = 1){ cout 33 catch (double et 34 cout 39 40 return 0; 41 ) What will the program print if the user enters the following input? i. -1 (3 marks) c. Given Program C-4 that shows an example use case where a function template is suitable to apply to 1 // Program C-4 2 3 int divisioni (int a, int b) { int c = a 7 b; 6 return; NO HA 8 9 double division2 (double a, int b) 10 11 double = a/ b; 12 return c; 13 i. Examine the program and justify why a function template is suitable to implement in the program? ii. Rewrite the program using a function template. (6 marks)

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!