-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPeeps.h
42 lines (35 loc) · 774 Bytes
/
Peeps.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
42
//
// Created by kwoodle on 12/1/17.
//
#ifndef CPPEXERCISES_PEEPS_H
#define CPPEXERCISES_PEEPS_H
#include <iostream>
#include <map>
#include <sstream>
#include <fstream>
#include <string>
using namespace std;
class Peeps {
public:
map<string, int> peeps;
};
ostream &operator<<(ostream &os, const Peeps &Peeps) {
for (auto& p : Peeps.peeps) {
os << "name: " << p.first << " age: " << p.second << "\n";
}
return os;
}
istream &operator>>(istream &is, Peeps &P) {
string line;
string nm;
int ag;
while (std::getline(is, line).good()) {
istringstream ss(line);
if (ss.str().length() == 0)
break;
ss >> nm >> ag;
P.peeps[nm] = ag;
}
return is;
}
#endif //CPPEXERCISES_PEEPS_H