-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathE22.h
37 lines (31 loc) · 767 Bytes
/
E22.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
#ifndef E22_H
#define E22_H
#include <string.h>
#include <iostream>
using namespace std;
struct Person;
istream &read(istream &, Person &);
struct Person
{
friend istream &read(istream &is, Person &person);
friend ostream &print(ostream &os, const Person &person);
public:
// construct
Person() = default;
Person (const string &s, const string &t) : name(s), address(t) {}
Person(istream &is){ read(is, *this); }
string getName() const {return name;}
string getAddress() const {return address;}
private:
string name;
string address;
};
istream &read(istream &is, Person &person) {
is >> person.name >> person.address;
return is;
}
ostream &print(ostream &os, const Person &person) {
os << person.name << " " << person.address;
return os;
}
#endif