小编use*_*704的帖子

cin >> operand无法使用枚举

这是我为练习做的代码.当我编译它时,它不允许cin >> choice被编译.它说" 错误2错误C2088:'>>':类非法 "和" 错误1错误C2371:'选择':重新定义;不同的基本类型 "我能就如何解决这个问题得到一些建议吗?非常感激!

#include <iostream>

using namespace std;

int main()
{
    cout << "Difficulty levels\n\n";
    cout << "Easy - 0\n";
    cout << "Normal - 1\n";
    cout << "Hard - 2\n";

    enum options { Easy, Normal, Hard, Undecided };
    options choice = Undecided;
    cout << "Your choice: ";
    int choice;
    cin >> choice;

    switch (choice)
    {
    case 0:
        cout << "You picked Easy.\n";
        break;
    case 1:
        cout << "You picked Normal. \n";
        break;
    case 2:
        cout << …
Run Code Online (Sandbox Code Playgroud)

c++ enums cin operands

2
推荐指数
1
解决办法
585
查看次数

标签 统计

c++ ×1

cin ×1

enums ×1

operands ×1