Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
0 of .
Results for:
P. 1
Hybrid Inheritance

# Hybrid Inheritance

Ratings: (0)|Views: 3,859|Likes:

### Availability:

See more
See less

03/18/2014

pdf

text

original

17. Multilevel Inheritance
class student{protected:int roll_no;public:void get_roll(int a) { roll_no=a; }void put_roll(void) { cout<<"Roll_no:"<<roll_no<<endl; }};class test : public student{protected:float sub1,sub2,sub3;public:void get_marks(float a,float b,float c) { sub1=a; sub2=b;sub3=c; }void put_marks(void){cout<<"Sub1="<<sub1<<endl;cout<<"Sub2="<<sub2<<endl;cout<<"Sub3="<<sub3<<endl;}};class result : public test{float total; //private member by defaultpublic:void display(void){total=sub1+sub2+sub3;put_roll();put_marks();cout<<"Total="<<total<<endl;}};int main(){result s1;s1.get_roll(501);s1.get_marks(60,75.7,89.34);s1.display();return (0);}
18. Hybrid Inheritance
1

class student{protected:int roll_no;public:void get_roll(int a) { roll_no=a; }void put_roll(void) { cout<<"Roll_no:"<<roll_no<<endl; }};class test : public student{protected:float sub1,sub2,sub3;public:void get_marks(float a,float b,float c) { sub1=a; sub2=b;sub3=c; }void put_marks(void){cout<<"Sub1="<<sub1<<endl;cout<<"Sub2="<<sub2<<endl;cout<<"Sub3="<<sub3<<endl;}};class sports{protected:float score;public:void get_score(float s) { score=s; }void put_score(void) { cout<<"Score="<<score<<endl;} };class result : public test,public sports{float total; //private member by defaultpublic:void display(void){total=sub1+sub2+sub3+score;put_roll();put_marks();put_score();cout<<"Total="<<total<<endl;}};int main(){result s1;s1.get_roll(501);s1.get_marks(60,75.7,89.34);2