-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA3book.cpp
84 lines (64 loc) · 953 Bytes
/
A3book.cpp
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
75
76
77
78
79
80
#include<iostream>
using namespace std;
class publication
{
public:
char title[20];
float price;
virtual void read()
{
cout<<"\nEnter the title:";
cin>>title;
cout<<"\nEnter the price:";
cin>>price;
}
virtual void show()
{
cout<<"Title:"<<title<<endl;
cout<<"Price:"<<price<<endl;
}
};
class book:public publication
{
public:
int page_count;
void read()
{
cout<<"\nEnter the no of pages:";
cin>>page_count;
}
void show()
{
cout<<"Page Count of book:"<<page_count<<endl;
}
};
class tape:public publication
{
public:
float playtime;
void read()
{
cout<<"\nEnter the time in minutes:";
cin>>playtime;
}
void show()
{
cout<<"Playing time in tape:"<<playtime<<endl;
}
};
int main()
{
publication *ptr;
publication obj;
book b;
tape t;
obj.read();
obj.show();
ptr=&b;
ptr->read();
ptr->show();
ptr=&t;
ptr->read();
ptr->show();
return 0;
}