18
ABHISHEK PRATAP ROLL NO. : 13-101

Hybrid Inheritance in C++

Embed Size (px)

DESCRIPTION

This presentation consist of a C++ code for Hybrid Inheritance by me.

Citation preview

Page 1: Hybrid Inheritance in C++

ABHISHEK PRATAPROLL NO. : 13-101

Page 2: Hybrid Inheritance in C++

#include<iostream.h>

#include<conio.h>

#include<string.h>

class Titan_showroom

{

protected:

char add[40],color[20],type[20];

public:

Titan_showroom()

{ strcpy(add,"Panjim");

strcpy(color,"White");

strcpy(type,"Analog");

}

Titan_showroom(char ad[],char co[],char ty[])

{ strcpy(add,ad);

strcpy(color,co);

strcpy(type,ty);

}

Page 3: Hybrid Inheritance in C++

void getdata1()

{ cout<<"\n::Enetr the details of Watch::\n";

cout<<"\nEnter the address of Showroom: ";

cin.getline(add,40);

cout<<"\nEnetr the colour of Watch: ";

cin.getline(color,20);

cout<<"\nEnetr the type of Watch: ";

cin.getline(type,20);

}

void display1()

{ cout<<"\n::Details of Watch::";

cout<<"\nAddress of showroom: "<<add;

cout<<"\nWatch colour: "<<color;

cout<<"\nWatch type: "<<type;

}

};

Page 4: Hybrid Inheritance in C++

class customer:public Titan_showroom

{

protected:

char name[30],date[20],phone[13];

public:

customer():Titan_showroom()

{ strcpy(name,"Abhay Singh");

strcpy(date,"23-09-2014");

strcpy(phone,"9427711999");

}

customer(char ad[],char co[],char ty[],char na[],char da[],char

ph[]):Titan_showroom(ad,co,ty)

{ strcpy(name,na);

strcpy(date,da);

strcpy(phone,ph);

}

Page 5: Hybrid Inheritance in C++

void getdata2()

{ clrscr();

cout<<"\n::::::::::::::::::::::::::||||Abhishek

Pratap||||:::::::::::::::::::::::::::\n\n";

cout<<"\n**Enter Details**\n";

cout<<"\n::Enetr the details of Customer::\n";

cout<<"\nEnter the name of Customer: ";

cin.getline(name,30);

cout<<"\nEnetr the date of purchase: ";

cin.getline(date,20);

cout<<"\nEnetr the phone no. of Customer: ";

cin.getline(phone,13);

}

void display2()

{ cout<<"\n\n::Details of Customer::";

cout<<"\nName of Customer: "<<name;

cout<<"\nDate of purchase: "<<date;

cout<<"\nPhone no. of Customer: "<<phone;

}

};

Page 6: Hybrid Inheritance in C++

class discount

{

protected:

float price,dis,disp,prip;

public:

discount()

{ price=890;

dis=0;

disp=price*dis/100;

prip=price-disp;

}

discount(float pr,float di)

{ price=pr;

dis=di;

disp=price*dis/100;

prip=price-disp;

}

Page 7: Hybrid Inheritance in C++

void getdata3()

{ clrscr();

cout<<"\n::::::::::::::::::::::::::||||Abhishek

Pratap||||:::::::::::::::::::::::::::\n\n";

cout<<"\n**Enter Details**\n";

cout<<"\n::Enetr the details of Discount::\n";

cout<<"\nDISCOUNT ON WATCH COST'S MORE

THAN OR EQUAL TO RS.1000\n";

cout<<"\nEnter the price of Watch: ";

cin>>price;

disc();

}

void disc()

{ if(price>=1000)

{ cout<<"\nEnter the discount percentage: ";

cin>>dis;

disp=price*dis/100;

}

prip=price-disp;

}

};

Page 8: Hybrid Inheritance in C++

class bill:public customer,discount

{

protected:

long int bill_no;

public:

bill():customer(),discount()

{ bill_no=10294;

}

bill(char ad[],char co[],char ty[],char na[],char da[],char ph[],float

pr,float di,long int bn):customer(ad,co,ty,na,da,ph),discount(pr,di)

{ bill_no=bn;

}

void getdata4()

{ Titan_showroom::getdata1();

customer::getdata2();

discount::getdata3();

clrscr();

cout<<"\n::::::::::::::::::::::::::||||Abhishek

Pratap||||:::::::::::::::::::::::::::\n\n";

cout<<"\n**Enter Details**\n";

Page 9: Hybrid Inheritance in C++

cout<<"\n::Eneter the details of Bill::\n";

cout<<"\nEnetr the Bill no.: ";

cin>>bill_no;

}

void display4()

{ Titan_showroom::display1();

customer::display2();

cout<<"\n\n::Bill::";

cout<<"\nBill no.: "<<bill_no;

cout<<"\nCost of Watch: "<<price;

cout<<"\nDisccount percentage: "<<dis;

cout<<"\nDiscount amount: "<<disp;

cout<<"\nAmount payable: "<<prip;

}

};

Page 10: Hybrid Inheritance in C++

void main()

{ clrscr();

bill b1,b2;

cout<<"\n::::::::::::::::::::::::::||||Abhishek Pratap||||:::::::::::::::::::::::::::\n\n";

cout<<"\n**Enter Details**\n";

b1.getdata4();

clrscr();

cout<<"\n::::::::::::::::::::::::::||||Abhishek Pratap||||:::::::::::::::::::::::::::\n\n";

cout<<"\n**Details**\n";

b1.display4();

getch();

clrscr();

cout<<"\n::::::::::::::::::::::::::||||Abhishek Pratap||||:::::::::::::::::::::::::::\n\n";

cout<<"\n**Default construtor**\n";

cout<<"\n**Details**\n";

b2.display4();

getch();

clrscr();

cout<<"\n::::::::::::::::::::::::::||||Abhishek Pratap||||:::::::::::::::::::::::::::\n\n";

cout<<"\n**Parameterised construtor**\n";

cout<<"\n**Details**\n";

bill b3("Margaon","Red","Digital","Ajay Kumar","10-06-2014","8806457389",1500,40,123045);

b3.display4();

getch();

clrscr();

}

Page 11: Hybrid Inheritance in C++

OUT PUT

Page 12: Hybrid Inheritance in C++
Page 13: Hybrid Inheritance in C++
Page 14: Hybrid Inheritance in C++
Page 15: Hybrid Inheritance in C++
Page 16: Hybrid Inheritance in C++
Page 17: Hybrid Inheritance in C++
Page 18: Hybrid Inheritance in C++