gpt4 book ai didi

C++ 错误 C2660 : Function does not take 3 arguments

转载 作者:行者123 更新时间:2023-11-30 00:49:51 26 4
gpt4 key购买 nike

我正在绞尽脑汁想弄清楚。我知道这很简单,但我需要一双新眼睛来弄清楚我错过了什么?

行包含下面的**,从底部开始第 7 行

我收到错误 C2660:“drillOneProblem”:函数不接受 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;
}

最佳答案

参数需要在函数声明的括号内声明。

所以这样:

void drillOneProblem()
{
int c, r1, r2; // passed-in parameters

应该是这样的:

void drillOneProblem(int c, int r1, int r2)
{

关于C++ 错误 C2660 : Function does not take 3 arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26922206/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com