switch/case statement in C++ with a QString type

后端 未结 14 2081
南笙
南笙 2020-12-16 10:19

I want to use switch-case in my program but the compiler gives me this error:

switch expression of type \'QString\' is illegal

How can I us

14条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 10:35

    This seems a little saner IMHO.

    bool isStopWord( QString w ) {
        return (
            w == "the" ||
            w == "at" ||
            w == "in" ||
            w == "your" ||
            w == "near" ||
            w == "all" ||
            w == "this"
        );
    }
    

提交回复
热议问题