我绞尽脑汁想出这个......我知道它的一些简单但我需要一套新的眼睛来弄清楚我错过了什么?
行包含**,从底部开始第7行
我收到错误C2660:' drillOneProblem' :function不带3个参数。请帮忙!
// Drill into problem
void drillOneProblem()
{
int c, r1, r2; // passed-in parameters
int CorAns; // correct answer
int reply; // user's answer
// Ask first part of question and display first random number
cout << "\nWhat is " << r1;
// Display sign based on user's answer
switch (c)
{
case '1': cout << " + ";
CorAns = r1 + r2;
break;
case '2': cout << " - ";
CorAns = r1 - r2;
break;
case '3': cout << " * ";
CorAns = r1 * r2;
break;
}
// Finish question and display second random number
// Ask answer, validate answer and display message
cout << r2 << " ? ";
cin >> reply;
if (reply == CorAns)
{
cout << "Yes, that is corret. Good job!";
}
else
cout << "No, the correct answer is: " << CorAns << endl << endl;
}
int main()
{
int c; // user's menu choice
int r1, r2; // random numbers
//Display Menu
displayMenu();
// Get user's choice and validate if out of range
c = getMenuChoice();
// Continue with program if user doesn't quit
while (c >= 1 && c < SENT)
{
// Generate random numbers
Gen2Rand(r1, r2);
// Display question based on user's menu choice request answer and validate answer.
// Display message to show if correct or not correct. If not correct display correct answer
**drillOneProblem(c, r1, r2);**
// display menu again and ask for menu choice after problem has been processed, repeat until
user quits
displayMenu();
c = getMenuChoice();
} return 0;
}
答案 0 :(得分:3)
参数需要在函数声明的括号中声明。
所以这个:
void drillOneProblem()
{
int c, r1, r2; // passed-in parameters
应该是这样的:
void drillOneProblem(int c, int r1, int r2)
{
答案 1 :(得分:2)
将您的职能声明为
void drillOneProblem(int c, int r1, ,int r2)
并在函数
中删除具有相同名称的局部变量答案 2 :(得分:1)
您的功能声明(第一行)中没有参数
void drillOneProblem()
它应该是:
void drillOneProblem(int c, int r1, int r2){
答案 3 :(得分:0)
你的宣言中没有参数
void drillOneProblem()
它应该是
void drillOneProblem(int c,r1,r2);
你应该删除你的fuc中的varriables,如:
void drillOneProblem(int c, r1, r2)
{
//int c, r1, r2; // passed-in parameters
.....
}