Write a program of student details using virtual in c++
#include<iostream.h>
#include<conio.h>
class student
{
long rollno;
public:
void putdata()
{
cout<<"\n ENter the Roll Number: ";
cin>>rollno;
}
void getdata()
{
cout<<"\n\n\t Roll number is : "<<rollno;
}
};
class exam: virtual public student
{
public:
int cpp,java;
void putmarks()
{
cout<<"\n Enter the marks of cplusplus: ";
cin>>cpp;
cout<<"\n Enter the marks of java: ";
cin>>java;
}
void getmarks()
{
cout<<"\n\n Marks obtained ";
cout<<"\n\t Marks of CPlusPlus is : "<<cpp;
cout<<"\n\t Marks of Java is : "<<java;
}
};
class behaviour: virtual public student
{
public:
int skill;
void putbehave()
{
cout<<"\n ENter the score of Behaviour: ";
cin>>skill;
}
void getbehave()
{
cout<<"\n\t Behaviour Marks : "<<skill;
}
};
class result: public exam, public behaviour
{
int total,avg;
public:
void show()
{
total=cpp+java+skill;
cout<<"\n Total marks is : "<<total;
avg=total/3;
cout<<"\n Average is : "<<avg;
}
};
void main()
{
clrscr();
result d1;
d1.putdata();
d1.putmarks();
d1.putbehave();
d1.show();
getch();
}
#include<conio.h>
class student
{
long rollno;
public:
void putdata()
{
cout<<"\n ENter the Roll Number: ";
cin>>rollno;
}
void getdata()
{
cout<<"\n\n\t Roll number is : "<<rollno;
}
};
class exam: virtual public student
{
public:
int cpp,java;
void putmarks()
{
cout<<"\n Enter the marks of cplusplus: ";
cin>>cpp;
cout<<"\n Enter the marks of java: ";
cin>>java;
}
void getmarks()
{
cout<<"\n\n Marks obtained ";
cout<<"\n\t Marks of CPlusPlus is : "<<cpp;
cout<<"\n\t Marks of Java is : "<<java;
}
};
class behaviour: virtual public student
{
public:
int skill;
void putbehave()
{
cout<<"\n ENter the score of Behaviour: ";
cin>>skill;
}
void getbehave()
{
cout<<"\n\t Behaviour Marks : "<<skill;
}
};
class result: public exam, public behaviour
{
int total,avg;
public:
void show()
{
total=cpp+java+skill;
cout<<"\n Total marks is : "<<total;
avg=total/3;
cout<<"\n Average is : "<<avg;
}
};
void main()
{
clrscr();
result d1;
d1.putdata();
d1.putmarks();
d1.putbehave();
d1.show();
getch();
}
No comments:
Post a Comment