Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C++でintをenumにキャストするにはどうすればよいですか?
例えば:
enum Test { A, B }; int a = 1;
aタイプに変換するにはどうすればよいTest::Aですか?
a
Test::A
int i = 1; Test val = static_cast<Test>(i);
Test e = static_cast<Test>(1);
あなたのコード
enum Test { A, B } int a = 1;
解決
Test castEnum = static_cast<Test>(a);