#include<iostream.h>
#include<conio.h>
class
Student
{
protected:
int roll;
public:
void
get_num(int);
void
put_num();
};
void
Student::get_num(int a)
{
roll=a;
}
void
Student::put_num()
{
cout<<"Roll
number is "<<roll<<"\n";
}
class
Test:virtual public Student
{
protected:
float
sub1,sub2;
public:
void get_mks(float,float);
void
put_mks();
};
void
Test::get_mks(float a,float b)
{
sub1=a;sub2=b;
}
void
Test::put_mks()
{
cout<<"marks
in sub1= "<<sub1<<"\n";
cout<<"marks
in sub2= "<<sub2<<"\n";
}
class
Sports: public virtual Student
{
protected:
float score;
public:
void
get_score()
{
cout<<"enter
the score marks\n";
cin>>score;
}
void
put_score()
{
cout<<"\nThe
score of the student is= "<<score;
}
};
class
Result:public Test,public Sports
{
float total;
public:
void
display();
};
void
Result::display()
{
total=float(sub1+sub2+score);
put_num();
put_mks();
put_score();
cout<<"\ntotal
= "<<total<<"\n";
}
void main()
{
int r;
float s1,s2;
Result obj;
clrscr();
cout<<"enter
the Roll no of Student\n";
cin>>r;
cout<<"\nenter
the marks of the student in 2 subject\n";
cin>>s1>>s2;
obj.get_score();
obj.get_num(r);
obj.get_mks(s1,s2);
obj.display();
getch();
}
Output