-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBookCollection.cpp
48 lines (38 loc) · 982 Bytes
/
BookCollection.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
#include<iostream>
#include<vector>
#include<string>
using namespace std;
class Book{
string title;
double price;
string author;
public :
Book (string n, string a, double p) {
price = p;
title = n;
author = a;
}
void display() const {
cout<<"[ Title of the Book : "<<title<<" , ";
cout<<"Author of the Book : "<<author<<" , ";
cout<<"Price of the Book : $ "<<price<<" ]"<<endl;
}
void updateprice (double np) {
price = np;
}
};
int main(){
vector<Book> collection;
collection.push_back(Book("Newtown","Admin",0.00));
collection.push_back(Book("Environment","Admin",0.00));
for (Book& book : collection) {
book.display();
cout << "------------------------" << endl<<endl;
}
collection[1].updateprice(01);
cout<<"updated price tags --->"<<endl<<endl;
for ( const Book& book : collection){
book.display();
}
return 0;
}