出现意外的非限定id错误 我刚开始用C++,使用XCODE。我试图写一个简单的,如果用户工作x金额用户得到支付y金额,程序。我不确定我所说的是否正确,但我无法测试它,因为我在第一个{行上得到了一个错误“Expected unqualified id”。这是列出的唯一错误,我不知道如何修复它 #include <iostream> using namespace std; int main () int user; int salary1 = user * 12; int salary2 = (user * 18) + 480; { // this is the line I'm receiving error. cout << "Enter the number of hours you worked this week"; cin >> user; if (user <= 40) { cout << "You made" << salary1 << "this week!" } else (user > 40) { cout << "You made" << salary2 << "this week!!!" } return 0; } #包括 使用名称空间std; int main() int用户; int salary1=用户*12; int salary2=(用户*18)+480; {//这是我收到的线路错误。 cout>用户; 如果(用户
大括号环绕整个功能体:出现意外的非限定id错误 我刚开始用C++,使用XCODE。我试图写一个简单的,如果用户工作x金额用户得到支付y金额,程序。我不确定我所说的是否正确,但我无法测试它,因为我在第一个{行上得到了一个错误“Expected unqualified id”。这是列出的唯一错误,我不知道如何修复它 #include <iostream> using namespace std; int main () int user; int salary1 = user * 12; int salary2 = (user * 18) + 480; { // this is the line I'm receiving error. cout << "Enter the number of hours you worked this week"; cin >> user; if (user <= 40) { cout << "You made" << salary1 << "this week!" } else (user > 40) { cout << "You made" << salary2 << "this week!!!" } return 0; } #包括 使用名称空间std; int main() int用户; int salary1=用户*12; int salary2=(用户*18)+480; {//这是我收到的线路错误。 cout>用户; 如果(用户,c++,C++,大括号环绕整个功能体: int main() { // <--- function body starts here int user; // rest of function body } // <--- function body ends here intmain() {/在int主块内声明变量,并在收到用户输入后计算工资 #include <iostream> using namespace std; int main () {
int main()
{ // <--- function body starts here
int user;
// rest of function body
} // <--- function body ends here
intmain()
{/在int主块内声明变量,并在收到用户输入后计算工资
#include <iostream>
using namespace std;
int main ()
{
int user;
cout << "Enter the number of hours you worked this week";
cin >> user;
int salary1 = user * 12;
int salary2 = (user * 18) + 480;
if (user <= 40)
{
cout << "You made" << salary1 << "this week!"
}
else (user > 40)
{
cout << "You made" << salary2 << "this week!!!"
}
return 0;
}
#包括
使用名称空间std;
int main()
{
int用户;
cout>用户;
int salary1=用户*12;
int salary2=(用户*18)+480;
如果(用户intmain(){/*