switch quantity not an integer

C++中,switch的选择因子只能是整数。

比如以下代码就不能通过编译


    String s = u->val;
    switch (s)
    {
    case "<":
    case "=" :
        return "Op:" + s;
    case "read" :
        return "Read";
    case "write" :
        return "Write";
    case ":=" :
        return "Assign to:";
    case "repeat" :
        return "Repeat";
    case "do" :
        return "Do";
    case "while" :
        return "While";
    case "for" :
        return "For";
    }


你可能感兴趣的:(C/C++)