forked from Mooophy/Cpp-Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex7_15.h
41 lines (32 loc) · 810 Bytes
/
ex7_15.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
38
39
40
41
//
// ex7_15.h
// Exercise 7.15
//
// Created by pezy on 11/9/14.
//
#ifndef CP5_ex7_15_h
#define CP5_ex7_15_h
#include <string>
#include <iostream>
struct Person;
std::istream &read(std::istream&, Person&);
struct Person {
Person() = default;
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){ }
Person(std::istream &is){ read(is, *this); }
std::string getName() const { return name; }
std::string getAddress() const { return address; }
std::string name;
std::string address;
};
std::istream &read(std::istream &is, Person &person)
{
is >> person.name >> person.address;
return is;
}
std::ostream &print(std::ostream &os, const Person &person)
{
os << person.name << " " << person.address;
return os;
}
#endif