-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay13.cpp
43 lines (40 loc) · 888 Bytes
/
Day13.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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
class Book{
protected:
string title;
string author;
public:
Book(string t,string a){
title=t;
author=a;
}
virtual void display()=0;
};
// Write your MyBook class here
class MyBook: Book{
private:
double price;
public:
MyBook(string title, string author, double price): Book(title, author), price(price){}
void display(){
cout<<"Title: "<<title<<endl;
cout<<"Author: "<<author<<endl;
cout<<"Price: "<<price;
}
};
int main() {
string title,author;
int price;
getline(cin,title);
getline(cin,author);
cin>>price;
MyBook novel(title,author,price);
novel.display();
return 0;
}