C++ string to enum

前端 未结 12 1297
无人及你
无人及你 2020-11-29 12:01

Is there a simple way in C++ to convert a string to an enum (similar to Enum.Parse in C#)? A switch statement would be very long, so I was wondering i

12条回答
  •  盖世英雄少女心
    2020-11-29 12:51

    No, you'll have to use an if/then construction, or use a map or hash table or some other type of associative data structure to facilitate this.

提交回复
热议问题