如何在C++中随机选择枚举类型的值?我想做这样的事情。
enum my_type(A,B,C,D,E,F,G,h,J,V); my_type test(rand() % 10);
但这是非法的..。不存在从int到枚举类型的隐式转换。
发布于 2010-06-09 00:03:06
没有隐式转换,但可以使用显式转换:
my_type test = my_type(rand() % 10);
https://stackoverflow.com/questions/2999012
相似问题