#include <iostream>
enum NavigationState {
PLANNING,
CONTROLLING,
CLEARING
};
int main() {
NavigationState state = CLEARING;
if (state == PLANNING) {
std::cout << "Currently in planning state" << std::endl;
} else if (state == CONTROLLING) {
std::cout << "Currently in controlling state" << std::endl;
} else if (state == CLEARING) {
std::cout << "Currently in clearing state" << std::endl;
}
return 0;
}
上述代码定义了一个枚举类型NavigationState
,并创建了一个state
变量并初始化为PLANNING
。接着使用if-else
语句根据不同的状态进行判断并输出相应的信息。在这个例子中,输出结果将为"Currently in clearing state