質問編集履歴

2

エラー

2019/02/24 05:05

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,28 +1,10 @@
1
- cinでvector配列に文字列を代入しようしたのすがコンパイルエラーになりした
1
+ cinofsのころでエラーが出てい
2
2
 
3
3
  ## エラー(一部)
4
4
 
5
- strategy.h: In member function 'void MCR::MCR_file_put(int)':
5
+ no operator ">>" matches these operands -- operand types are: std::basic_istream<char, std::char_traits<char>> >> <unknown-type>
6
6
 
7
- strategy.h:32:13: error: no match for 'operator>>' (operand types are 'std::istream {aka std::basic_istream<char>}' and 'std::vector<std::__cxx11::basic_string<char> > []')
7
+ no operator "<<" matches these operands -- operand types are: std::ofstream << std::vector<std::string, std::allocator<std::string>>
8
-
9
- cin >> strategy_data >> endl;
10
-
11
-
12
-
13
- In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:40:0,
14
-
15
- from strategy.h:4,
16
-
17
- from strategy.cpp:1:
18
-
19
- c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\istream:168:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT
20
-
21
- = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match>
22
-
23
- operator>>(bool& __n)
24
-
25
-
26
8
 
27
9
  ```c++
28
10
 
@@ -38,6 +20,10 @@
38
20
 
39
21
  #include <vector>
40
22
 
23
+ #include <string>
24
+
25
+
26
+
41
27
 
42
28
 
43
29
  using std::cout;
@@ -52,15 +38,19 @@
52
38
 
53
39
  using std::vector;
54
40
 
41
+ using std::string;
42
+
43
+
44
+
55
45
 
56
46
 
57
47
  const int x=100;
58
48
 
59
- extern vector<string> strategy_data[];
49
+ extern vector<string> strategy_data;//[]付けない
60
50
 
61
- extern vector<string> cause_data[];
51
+ extern vector<string> cause_data;
62
52
 
63
- extern vector<string> reflection_data[];
53
+ extern vector<string> reflection_data;
64
54
 
65
55
 
66
56
 
@@ -68,7 +58,13 @@
68
58
 
69
59
  class MCR{
70
60
 
61
+
62
+
71
-
63
+ string strategy_data_source;
64
+
65
+ string cause_data_source;
66
+
67
+ string reflection_data_source;
72
68
 
73
69
  public:
74
70
 
@@ -88,7 +84,9 @@
88
84
 
89
85
  ofstream ofs("MCR_strategy.txt",std::ios::app);
90
86
 
91
- cin >> strategy_data >> endl;
87
+ cin >> strategy_data_source >> endl;
88
+
89
+ strategy_data.push_back(strategy_data_source);
92
90
 
93
91
  ofs << strategy_data << endl;
94
92
 
@@ -102,7 +100,9 @@
102
100
 
103
101
  ofstream ofs("MCR_cause.txt",std::ios::app);
104
102
 
105
- cin >> cause_data >> endl;
103
+ cin >> cause_data_source >> endl;
104
+
105
+ cause_data.push_back(cause_data_source);
106
106
 
107
107
  ofs << cause_data << endl;
108
108
 
@@ -116,7 +116,9 @@
116
116
 
117
117
  ofstream ofs("MCR_reflection.txt",std::ios::app);
118
118
 
119
- cin >> reflection_data >> endl;
119
+ cin >> reflection_data_source >> endl;
120
+
121
+ reflection_data.push_back(reflection_data_source);
120
122
 
121
123
  ofs << reflection_data << endl;
122
124
 

1

ミス

2019/02/24 05:05

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  cinでvector配列に文字列を代入しようとしたのですがコンパイルエラーになりました。
2
2
 
3
- ## エラー
3
+ ## エラー(一部)
4
4
 
5
5
  strategy.h: In member function 'void MCR::MCR_file_put(int)':
6
6