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