typedef enum

nac*_*o4d 3 c++ enums typedef

typedef enum{
 Adjust_mode_None = 0,
 Adjust_mode_H_min,
 Adjust_mode_H_max,
 Adjust_mode_S_min,
 Adjust_mode_S_max,
 Adjust_mode_V_min,
 Adjust_mode_V_max
}Adjust_mode;
Run Code Online (Sandbox Code Playgroud)

在某些时候我想做:

adjust_mode_ = (adjust_mode_+1)%7; 
Run Code Online (Sandbox Code Playgroud)

但我得到从int到Adjust_mode的无效转换

这在其他语言中没问题,C++有什么问题?我需要定义一些运算符吗?

aJ.*_*aJ. 5

static_cast.您需要显式转换.

adjust_mode_ = static_cast<Adjust_mode>(adjust_mode_+1)%7;
Run Code Online (Sandbox Code Playgroud)