回答編集履歴

3

追記

2019/09/12 12:31

投稿

episteme
episteme

スコア16614

test CHANGED
@@ -6,7 +6,11 @@
6
6
 
7
7
  ```
8
8
 
9
+
10
+
11
+ [追記]
12
+
9
- ```
13
+ ```C++
10
14
 
11
15
  // C++ : お好きなものをどうぞ
12
16
 
@@ -17,3 +21,39 @@
17
21
  std::vector<std::string> text = { "Apple", "Orange", "Red" };
18
22
 
19
23
  ```
24
+
25
+
26
+
27
+ [追記]
28
+
29
+ ```C++
30
+
31
+ #include <array>
32
+
33
+ #include <vector>
34
+
35
+ #include <string>
36
+
37
+ #include <iostream>
38
+
39
+
40
+
41
+ int main() {
42
+
43
+ std::array<std::string,3> text1 = { "Apple", "Orange", "Red" };
44
+
45
+ std::vector<std::string> text2 = { "Apple", "Orange", "Red" };
46
+
47
+ std::string text3[] = { "Apple", "Orange", "Red" };
48
+
49
+
50
+
51
+ for ( const auto& item : text1 ) std::cout << item << ' '; std::cout << std::endl;
52
+
53
+ for ( const auto& item : text2 ) std::cout << item << ' '; std::cout << std::endl;
54
+
55
+ for ( const auto& item : text3 ) std::cout << item << ' '; std::cout << std::endl;
56
+
57
+ }
58
+
59
+ ```

2

微修正

2019/09/12 12:31

投稿

episteme
episteme

スコア16614

test CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  // C++ : お好きなものをどうぞ
12
12
 
13
- std::string test[] = { "Apple", "Orange", "Red" };
13
+ std::string text[] = { "Apple", "Orange", "Red" };
14
14
 
15
15
  std::array<std::string,3> text = { "Apple", "Orange", "Red" };
16
16
 

1

追記

2019/09/12 12:24

投稿

episteme
episteme

スコア16614

test CHANGED
@@ -1,5 +1,19 @@
1
1
  ```C
2
+
3
+ /* C */
2
4
 
3
5
  const char* text[] = { "Apple", "Orange", "Red" };
4
6
 
5
7
  ```
8
+
9
+ ```
10
+
11
+ // C++ : お好きなものをどうぞ
12
+
13
+ std::string test[] = { "Apple", "Orange", "Red" };
14
+
15
+ std::array<std::string,3> text = { "Apple", "Orange", "Red" };
16
+
17
+ std::vector<std::string> text = { "Apple", "Orange", "Red" };
18
+
19
+ ```