//PROGRAM TO IMPLEMENT HYBRID INHERITENCE
/*MADE BY KRISHNA AGARWAL*/
#include<iostream.h>
#include<conio.h>
class student
{
protected:
int roll_number;
public:
void get_number();
void put_number();
};
void student::get_number()
{
cout<<"enter the roll number\n";
cin>>roll_number;
}
void student::put_number()
{
cout<<"\nthe roll number is = "<<roll_number;
}
class test:public student
{
protected:
float part1, part2;
public:
void get_marks();
void put_marks();
};
void test::get_marks()
{
cout<<"\nenter the marks of part one and part two\n";
cin>>part1>>part2;
}
void test::put_marks()
{
cout<<"\nmarks in part 1 is = "<<part1;
cout<<"\nmarks in part 2 is = "<<part2;
}
class sports
{
protected:
float scores;
public:
void get_score()
{
cout<<"\nenter the score\n";
cin>>scores;
}
void put_score()
{
cout<<"\nthe score is = "<<scores;
}
};
class result: public test, public sports
{
float total;
public:
void display()
{
total=part1+part2+scores;
put_number();
put_score();
put_marks();
cout<<"\ntotal is = "<<total;
}
};
void main()
{
clrscr();
result student_1;
student_1.get_number();
student_1.get_marks();
student_1.get_score();
student_1.display();
getch();
}
/*MADE BY KRISHNA AGARWAL*/
#include<iostream.h>
#include<conio.h>
class student
{
protected:
int roll_number;
public:
void get_number();
void put_number();
};
void student::get_number()
{
cout<<"enter the roll number\n";
cin>>roll_number;
}
void student::put_number()
{
cout<<"\nthe roll number is = "<<roll_number;
}
class test:public student
{
protected:
float part1, part2;
public:
void get_marks();
void put_marks();
};
void test::get_marks()
{
cout<<"\nenter the marks of part one and part two\n";
cin>>part1>>part2;
}
void test::put_marks()
{
cout<<"\nmarks in part 1 is = "<<part1;
cout<<"\nmarks in part 2 is = "<<part2;
}
class sports
{
protected:
float scores;
public:
void get_score()
{
cout<<"\nenter the score\n";
cin>>scores;
}
void put_score()
{
cout<<"\nthe score is = "<<scores;
}
};
class result: public test, public sports
{
float total;
public:
void display()
{
total=part1+part2+scores;
put_number();
put_score();
put_marks();
cout<<"\ntotal is = "<<total;
}
};
void main()
{
clrscr();
result student_1;
student_1.get_number();
student_1.get_marks();
student_1.get_score();
student_1.display();
getch();
}
No comments:
Post a Comment