0

This code is ok on QT SDK (installed on Windows) but reports expected expression error on Xcode 4 (Mac).

#include <iostream>
using namespace std;
int main() {
    bool quit = false; // Flag for quitting
    while(quit == false) {
        cout << "Select a, b, c or q to quit: ";
        char response;
        cin >> response;
        switch(response) {
        case 'a' :
            cout << "you chose 'a'" << endl;
            break;
        case 'b' :
            cout << "you chose 'b'" << endl;
            break;
        case 'c' :
            cout << "you chose 'c'" << endl;
            break;
        case 'q' :
            cout << "quitting menu" << endl;
            quit = true;
            break;
        default :
            cout << "Please use a,b,c or q!" << endl;
        }
    }
} ///:~

The error is displayed on default instruction: "expected expression".

4

1 回答 1

0

我解决了这个问题,但我不明白它的根源。假设从 Eckel 关于 QT sdk 的书中复制的代码没有出错,我尝试删除第一个闭合花括号之前的一些空格,因此我也在 Xcode 平台上成功构建/运行。是不是很奇怪?Boh SW的奥秘。

于 2012-11-07T10:56:08.267 回答