-6

次のコード ブロックが機能しません。コンパイラは、 for には引数が必要だと言っています。

正確なエラー メッセージは、Expected an Expression です。

alfa_it = alfa_list.begin();
cout << "the parties that are flying on Alfa are";
cout << for (alfa_it = alfa_list.begin(); alfa_it != alfa_list.end(); alfa_it++)
cout << " " << *alfa_it;
cout << endl;

ps alfa は意図的にスペルミスをしています。

4

1 に答える 1

4

forに引数として与えることはできませんcout::operator<<。あなたはおそらく探しているでしょう:

cout << "the parties that are flying on Alfa are";
for (alfa_it = alfa_list.begin(); alfa_it != alfa_list.end(); alfa_it++)
    cout << " " << *alfa_it;
cout << endl;
于 2012-12-07T01:26:54.453 に答える