Computer Science, asked by santhu10sachin, 5 months ago

24. Write a program having a base class Student with data member rollno and member

functions getnum() to input rollno and putnum() to display rollno.

A class Test is derived from class Student with data member marks and member functions

getmarks() to input marks and putmarks() to display marks. Class Sports is also derived

from class Student with data member score and member functions getscore() to input score

and putscore() to display score. The class Result is inherited from two base classes, class

Test and class Sports with data member total and a member function display() to display

rollno, marks, score and the total(marks + score).​

Answers

Answered by Anonymous
1

Simple Program for Virtual Base Class Algorithm/Steps:

  • Step 1: Start the program.
  • Step 2: Declare the base class student.
  • Step 3: Declare and define the functions getnumber() and putnumber().
  • Step 4: Create the derived class test virtually derived from the base class student.
  • Step 5: Declare and define the function getmarks() and putmarks().
  • Step 6: Create the derived class sports virtually derived from the base class student.
  • Step 7: Declare and define the function getscore() and putscore().
  • Step 8: Create the derived class result derived from the class test and sports.
  • Step 9: Declare and define the function display() to calculate the total.
  • Step 10: Create the derived class object obj.
  • Step 11: Call the function get number(),getmarks(),getscore() and display().
  • Step 12: Stop the program.

HOPE THIS HELPS YOU ❤️

Similar questions