Program for the implementation of hybrid inheritance.

#include
#include
class student
{
protected:
int roll_number;
public:
void get_number(int a)
{
roll_number=0;
}
void put_number()
{
cout<<roll_number<<endl;
}
};

class test:public student
{
protected:
float sub1,sub2;
public:
void get_marks(float x,float y)
{
sub1=x;
sub2=y;
}
void put_marks()
{
cout<<sub1<<endl<<sub2<<endl;
}
};

class score
{
protected:
float score;
public:
void get_score(float s)
{
score=s;
}
void put_score()
{
cout<<score<<endl;
}
};

class result:public test,public score
{
protected:
float total;
public:
void display()
{
total=sub1+sub2+score;
put_number();
put_marks();
put_score();
cout<<total;
}
};

void main()
{
result r;
clrscr();
r.get_number(45);
r.get_marks(55.5,44.6);
r.get_score(9.0);
r.display();
getch();
}

Leave a reply