-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPhone.h
37 lines (34 loc) · 1.06 KB
/
Phone.h
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
#pragma once
#include <string>
#include <fstream>
using namespace std;
class Phone
{
private:
string phoneNumber;
public:
Phone();
~Phone();
void clear() { phoneNumber.shrink_to_fit(); }
void set_number(string number); // »ñÈ¡ÊÖ»úºÅ
void operator=(Phone nPhone) { phoneNumber = nPhone.phoneNumber; }
void operator<<(string number) { set_number(number); }
int operator==(string number) { return phoneNumber == number; }
int operator!=(string number) { return !(phoneNumber == number); }
string get_number()const { return phoneNumber; }
bool operator ==(Phone& nPhone)const { return nPhone.get_number() == phoneNumber; }
bool operator !=(Phone& nPhone)const { return !(*this == nPhone); }
friend fstream& operator<<(fstream& outFile, Phone& phone);
friend ostream& operator<<(ostream& outFile, Phone& phone);
};
static fstream& operator<<(fstream& outFile, Phone& phone)
{
outFile << phone.phoneNumber;
return outFile;
}
static ostream& operator<<(ostream& outFile, Phone& phone)
{
outFile << phone.phoneNumber;
return outFile;
}
;