Hybrid inheritence
Download
1 / 7

Hybrid Inheritence - PowerPoint PPT Presentation


  • 109 Views
  • Uploaded on

Hybrid Inheritence. Nazia Hossain Lecturer Stamford University. Hybrid Inheritance is the combination of two or more inheritances : single, multiple,multilevel or hierarchical Inheritances.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Hybrid Inheritence' - erol


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Hybrid inheritence

Hybrid Inheritence

Nazia Hossain

Lecturer

Stamford University


  • Hybrid Inheritance is the combination of two or more inheritances : single, multiple,multilevel or hierarchical Inheritances.

  • The following is a C++ Program to for Calculating the marks secured by a student.A Parent class with student identification is created and another class called marks is inherited from the main class.This class marks is further inherited by another class called sports and finally the sports class is inherited by the percentage class to calculated the percentage of marks.


#include< inheritances : single, iostream.h>

#include<conio.h>

#include<stdio.h>

#include<string.h>

void main()

{

intcont;

percentage pc;

clrscr();

do

{

pc.calculate();

clrscr();

pc.display_totp();

cout<<"\n\nDo You Want to Continue?(1-YES/0-NO)";

cin>>cont; }while(cont==1); getch();

}


class inheritances : single, student_id {

//c-madeeasy.blogspot.com

intrno;

char name[20];

public:

void read_id()

{

cout<<"\n\nEnter the Name of the Student : ";

gets(name);

cout<<"\n\nEnter the Roll No. : ";

cin>>rno;

}

void display_nr()

{

cout<<"\n\n\t\tSTUDENT REPORT\n\nNAME : ";

puts(name);

cout<<"\n\nROLL NO. : "<<rno;

}

};


class inheritances : single, marks:publicstudent_id

{

public:

inti,mark[3];

void read_m()

{

read_id();

for(i=0;i<3;i++) {

cout<<"\n\nEnter the Marks Secured in SUBJECT "<<i+1<<" out of 100 : ";

cin>>mark[i];

}

}

void display_m() {

display_nr();

cout<<"\n\n\tMarks Secured ";

for(i=0;i<3;i++)

cout<<"\n\nSUBJECT "<<i+1<<" : "<<mark[i];

}

};


class sports { inheritances : single,

public:

intsm;

void read_sportm()

{

cout<<"\n\nEnter the marks in SPORTS out of 10 : "; cin>>sm;

}

};


class inheritances : single, percentage:publicmarks,public sports

{

public: float total,prcntge;

void calculate()

{

read_m();

read_sportm();

total=0;

for(i=0;i<3;i++) {

total+=mark[i];

}

total+=sm; prcntge=(total/310)*100;

}

void display_totp()

{

display_m(); cout<<"\n\nTOTAL = "<<total; cout<<"\n\nPERCENTAGE = "<<prcntge;

}

};


ad