hybrid inheritance in c++
DESCRIPTION
This presentation consist of a C++ code for Hybrid Inheritance by me.TRANSCRIPT
ABHISHEK PRATAPROLL NO. : 13-101
#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);
}
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;
}
};
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);
}
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;
}
};
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;
}
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;
}
};
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";
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;
}
};
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();
}
OUT PUT