#include<iostream>
using namespace std;
class student
{
char name[10],clas[10];
int rn;
public:
void getdata()
{
cout<<"\n Enter the student name:";
cin>>name;
cout<<"\n Enter the roll no:";
cin>>rn;
cout<<"\n Enter the class:";
cin>>clas;
}
void putdata()
{
cout<<"\n Student name:"<<name;
cout<<"\n Roll no:"<<rn;
cout<<"\n Class:"<<clas;
}
};
class test:virtual public student
{
public:
int p1,p2;
void part1()
{
cout<<"\n Enter the mark of part1:";
cin>>p1;
}
void part2()
{
cout<<"\n Enter the mark of part2:";
cin>>p2;
}
void display()
{
cout<<"\n Part1 marks:"<<p1;
cout<<"\n Part2 marks:"<<p2;
}
};
class sports:virtual public student
{
public:
int m;
void getmk()
{
cout<<"\n Enter the sports mark:";
cin>>m;
}
void putmk()
{
cout<<"\n Sports Mark:"<<m;
}
};
class result:public test,public sports
{
public:
int total;
void calc()
{
cout<<"\n MARKLIST";
total=p1+p2+m;
putdata();
display();
putmk();
cout<<"\n Total is "<<total;
}
};
int main()
{
cout<<"\nSTUDENT MARKLIST USING VIRTUAL BASE CLASS";
result n;
n.getdata();
n.part1();
n.part2();
n.getmk();
cout<<"\n RESULT";
n.calc();
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: