-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14.08.cpp
43 lines (35 loc) · 957 Bytes
/
14.08.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
// Exercise 14.08
// Define an outout operator for the class you chose in exercise 7.40
// Xiaoyan Wang 01/28/2017
// Written based on 7.40.cpp
#ifndef __14_08_CPP__
#define __14_08_CPP__
#include <iostream>
#include <string>
#include <vector>
using std::string;
using std::vector;
class Book {
public:
Book() = default;
Book(const string& t, double p) : title(t), price(p) {}
Book(const string& t,
const string& a,
const string& i,
double p,
const vector<string>& cvec)
: title(t), price(p), isbn(i), author(a), categories(cvec) {}
Book(const Book& other) = default;
friend std::ostream& operator<<(std::ostream&, const Book&);
private:
string title;
double price;
string isbn;
string author;
vector<string> categories;
};
std::ostream& operator<<(std::ostream& os, const Book& b) {
os << b.title << ", " << b.author << ", " << b.price;
return os;
}
#endif