出于某种原因,这个非常基本的代码将在Visual C中编译时没有错误,但在XCode中会出错.我需要知道为什么,为了继续在
Xcode中为我的计算机科学课程工作.
#include <iostream> #include <string> using namespace std; struct acct { // bank account data int num; // account number string name; // owner of account float balance; // balance in account }; int main() { acct account; cout << "Enter new account data: " << endl; cout << "Account number: "; cin >> account.num; cout << "Account name: "; cin >> account.name; cout << "Account balance: "; cin >> account.balance; return 0; }
它给出了两个错误,一个说它预期’;’在帐户之前(在声明主要之后),并且第二个帐户未被宣布为cin>> account.num;