這是我的代碼。我嘗試修復它,並且我總是獲得相同的錯誤:'int'之前的預期主表達式。error_expected_primary表達式之前。在函數中
在線路47,55,63,80,86
而且之前我已經嘗試過這個程序小塊和它的作品。它沒有標記該錯誤。
` 的#include
using namespace std;
int add (int a, int b)
{
int r;
r=a+b;
return (r);
}
int ssub (int a, int b)
{
int r;
r=a-b;
return (r);
}
int mult(int a, int b)
{
int r;
r=a*b;
return (r);
}
int menu(int a, int b){
int r;
char x;
cout <<"What do you want to do: \na.Adding \n s. Substract \n m. Multiply. \n. e. Exit"<<endl;
cin>>x;
switch (x){
case 'a':
cout << "Give a value for a"<<endl;
cin>>a;
cout <<"Give a value for b"<<endl;
cin>>b;
add (int a, int b); //aquí y en otras líneas me sale: expected primary expression before int.
break;
case 's':
cout << "Give a value for a"<<endl;
cin>>a;
cout <<"Give a value for b"<<endl;
cin>>b;
ssub (int a, int b);
break;
case 'm':
cout << "Give a value for a"<<endl;
cin>>a;
cout <<"Give a value for b"<<endl;
cin>>b;
mult (int a, int b);
break;
case 'e':
x='e';
break;
default:
cout<<"Wrong choice. Run the program again and choose another letter"<<endl;
break;
}
return r;
}
cout<<"The result is " << menu (int a, int b)<<endl;
int main()
{
menu (int a, int b);
return 0;
}
`
哪條線是47,55,63,80和86?誰偷了你的標籤鍵? – nhgrif