回答編集履歴
1
コード追記
test
CHANGED
@@ -1,3 +1,43 @@
|
|
1
1
|
C++17以降で良ければ、`static inline ~`で宣言時に初期化もできますよ。
|
2
2
|
|
3
3
|
[インライン変数](https://cpprefjp.github.io/lang/cpp17/inline_variables.html)
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
```C++
|
8
|
+
|
9
|
+
class Atom {
|
10
|
+
|
11
|
+
public:
|
12
|
+
|
13
|
+
enum Type { H, He, Li };
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
static inline const std::vector<std::string> Name = { "Hydrogen", "Helium", "Lithium" };
|
18
|
+
|
19
|
+
};
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
class Permisson {
|
24
|
+
|
25
|
+
public:
|
26
|
+
|
27
|
+
enum Type { Read = 1, Write = 2, Execute = 4 };
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
static inline const std::map<int, std::string> Name = {
|
32
|
+
|
33
|
+
{Permisson::Read, "Read"},
|
34
|
+
|
35
|
+
{Permisson::Write, "Write"},
|
36
|
+
|
37
|
+
{Permisson::Execute, "Execute"},
|
38
|
+
|
39
|
+
};
|
40
|
+
|
41
|
+
};
|
42
|
+
|
43
|
+
```
|