-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiple.cpp
More file actions
74 lines (73 loc) · 1.34 KB
/
Copy pathmultiple.cpp
File metadata and controls
74 lines (73 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//Program to implement multiple inheritance to calculate total revenue generated from the sales of books
#include<iostream>
using namespace std;
class publication
{
private:
char publisher[20];
protected:
double price;
public:
void read()
{
cout<<"Enter publisher and price : ";
cin>>publisher>>price;
}
void show()
{
cout<<"\nPublisher = "<<publisher;
cout<<"\nPrice = "<<price;
}
};
class sales
{
protected:
double pub_sales;
public:
void read()
{
cout<<"\nEnter total sales =";
cin>>pub_sales;
}
void show()
{
cout<<"\nTotal sales of publication ="<<pub_sales;
}
};
class book : public publication,public sales
{
char author[20];
long isbn;
int pages;
public:
void read()
{
cout<<"\nEnter author,isbn number,pages :";
cin>>author>>isbn>>pages;
}
void show()
{
cout<<"\nBook info: "<<author<<'\t'<<isbn<<'\t'<<pages;
}
void cal_sal_amt()
{
double saleamt;
saleamt=price*pub_sales;
cout<<"Sale amount= "<<saleamt;
}
};
int main()
{
book b1;
cout<<"Enter publication information..\n";
b1.publication::read();
cout<<"\nEnter sales information..";
b1.sales::read();
cout<<"Enter book information..";
b1.read();
b1.cal_sal_amt();
b1.publication::show();
b1.sales::show();
b1.show();
return 0;
}