-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson.h
43 lines (34 loc) · 845 Bytes
/
Person.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
43
/*
* Person.h
*
* Created on: 2 gru 2014
* Author: edek437
*/
#ifndef PERSON_H_
#define PERSON_H_
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
struct Person{
std::string name;
std::vector<std::string> chatbox;
bool is_new;
Person(std::string& in_name, std::string& in_message, bool b=true): name(in_name), is_new(b){
chatbox.push_back(in_message);
}
friend std::ostream &operator << (std::ostream& ost, const Person& P){
std::string new_message;
P.is_new ? new_message="NEW MESSAGE":new_message="nothing new";
ost<<P.name+": "+new_message;
return ost;
}
void display_contents(){
std::stringstream ss;
for(std::vector<std::string>::iterator vit=chatbox.begin();vit!=chatbox.end();vit++){
ss<<*vit<<"\n";
}
std::cout<<ss.str()<<std::endl;
}
};
#endif /* PERSON_H_ */