-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbook_ex49.cpp
66 lines (54 loc) · 1.23 KB
/
book_ex49.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
#include "book_ex49.h"
Book& Book::operator=(const Book &rhs)
{
this->no_ = rhs.no_;
this->name_ = rhs.name_;
this->author_ = rhs.author_;
this->pubdate_ = rhs.pubdate_;
return *this;
}
Book& Book::operator=(const Book &&rhs) noexcept
{
if(this != &rhs)
{
this->no_ = rhs.no_;
this->name_ = rhs.name_;
this->author_ = rhs.author_;
this->pubdate_ = rhs.pubdate_;
}
return *this;
}
std::istream& operator>>(std::istream &in, Book &book)
{
in >> book.no_ >> book.name_ >> book.author_ >> book.pubdate_;
return in;
}
std::ostream& operator<<(std::ostream &out, const Book &book)
{
out << book.no_ << " " << book.name_ << " " << book.author_ << " " << book.pubdate_;
return out;
}
bool operator==(const Book &lhs, const Book &rhs)
{
return lhs.no_ == rhs.no_;
}
bool operator!=(const Book &lhs, const Book &rhs)
{
return !(lhs == rhs);
}
bool operator<(const Book &lhs, const Book &rhs)
{
return lhs.no_ < rhs.no_;
}
bool operator>(const Book &lhs, const Book &rhs)
{
return rhs < lhs;
}
bool operator<=(const Book &lhs, const Book &rhs)
{
return !(rhs < lhs);
}
bool operator>=(const Book &lhs, const Book &rhs)
{
return !(lhs < rhs);
}