-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11week_2_1.cpp
35 lines (33 loc) · 932 Bytes
/
11week_2_1.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
#include <iostream>
#include <string>
using namespace std;
class Book{
string title;
int price, pages;
public:
Book(string title = "", int price = 0, int pages = 0){
this->title = title; this->price = price; this->pages = pages;
}
void show(){
cout << title << ' ' << price << "원 " << pages << " 페이지" << endl;
}
string getTitle() { return title; }
bool operator == (int x){
if (x == price) return true;
else return false;
}
bool operator == (string t){
if (title == t) return true;
else return false;
}
bool operator == (Book c){
if (title == c.title && price == c.price && pages == c.pages) return true;
else return false;
}
};
int main(){
Book a("명품 C++", 30000, 500), b("고품 C++", 30000, 500);
if (a == 30000) cout << "정가 30000원" << endl;
if (a == "명품 C++") cout << "명품 C++입니다." << endl;
if (a == b) cout << "두 책이 같은 책입니다." << endl;
}