AIM:
To implement a C++ program to find out the student details using multilevel inheritance.
To implement a C++ program to find out the student details using multilevel inheritance.
ALGORITHM:
Step 1: Include the header files
Step 2: Declare the base class student.
Step 3: Declare and define the function get_ number ( ) and put_number( ).
Step 4: Declare the derived class test for student
Step 5: Declare and define the function get_ marks ( ) and put_marks( ).
Step 6: Declare the derived class result for test
Step 7: Declare and define the function display ( )
Step 8: Create objects for the derived class.
Step 9: Declare the derived class object, call the functions get_ number ( ), get_ marks ( ), display ( ).
PROGRAM:
#include<iostream.h>
#include<conio.h>
class student
{
protected:
int roll;
public:
void get_number(int a)
{
roll = a;
}
void put_number()
{
cout<<"Roll Number: "<<roll<<"\n";
}
};
class test : public student
{
protected:
float sub1;
float sub2;
public:
void get_marks(float x,float y)
{
sub1 = x;
sub2 = y;
}
void put_marks()
{
cout<<"Marks in Subject 1 = "<<sub1<<"\n";
cout<<"Marks in Subject 2 = "<<sub2<<"\n";
}
};