-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultilevel_P8.cpp
More file actions
57 lines (57 loc) · 1.06 KB
/
Multilevel_P8.cpp
File metadata and controls
57 lines (57 loc) · 1.06 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
#include<iostream.h>
#include<conio.h>
class book
{
public:
int bookid;
char bname[30];
float price;
void input( );
};
void book::input( )
{
cout<<"\n Enter the Book ID: ";
cin>>bookid;
cout<<"\n Enter the Book Name: ";
cin.ignore();
cin.getline(bname,30);
cout<<"\n Enter the Price: ";
cin>>price;
}
class purchase:public book
{
public:
int quantity;
void inputquantity( );
};
void purchase::inputquantity( )
{
cout<<"\n Enter the Quantity Purchased:";
cin>>quantity;
}
class detail:public purchase
{
public:
void display( );
};
void detail::display( )
{
cout<<"\n\t\t BOOK DETAILS";
cout<<"\n\t\t ------------";
cout<<"\n\n Book ID :"<<bookid;
cout<<"\n\n Book Name :"<<bname;
cout<<"\n\n Unit Price :"<<price;
cout<<"\n\n Quantity :"<<quantity;
cout<<"\n\n Total Amount :"<<(price*quantity);
}
void main( )
{
detail ob;
clrscr( );
cout<<"\n\t\tBOOK DETAILS USING MULTILEVEL INHERITANCE";
cout<<"\n\t\t-----------------------------------------";
ob.input( );
ob.inputquantity( );
ob.display( );
getch( );
}