-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrain.h
57 lines (41 loc) · 1.08 KB
/
train.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <iostream>
#include <string>
#define NAME 0
#define NUMBER 1
#define TIME 2
using namespace std;
class train
{
string prop[3];
train* nextPtr;
public:
train();
string getName();
string getNumber();
string getType();
train* getNextPtr();
void setName(string str);
void setNumber(string str);
void setType(string str);
void setNextPtr(train* p);
friend std::ostream& operator<<(std::ostream& os, const train& p)
{
return os << "Íîìåð: " << p.prop[NUMBER] << " Ïóíêò íàçíà÷åíèÿ: " << p.prop[NAME] << " Âðåìÿ: " << p.prop[TIME] << endl;
}
friend std::istream& operator>>(std::istream& in, train& p)
{
std::cout << "Íîìåð: ";
in.clear();
in.ignore();
getline(in, p.prop[NUMBER]);
std::cout << "Ïóíêò íàçíà÷åíèÿ: ";
in.clear();
getline(in, p.prop[NAME]);
std::cout << "Âðåìÿ: ";
in.clear();
getline(in, p.prop[TIME]);
in.sync();
return in;
}
};