简体   繁体   English

C ++错误C2660:函数没有3个参数

[英]C++ Error C2660: Function does not take 3 arguments

I'm racking my brain to figure this out.. I know its something simple but I need a new set of eyes to figure out what I'm missing? 我正在绞尽脑汁去弄清楚。.我知道这很简单,但是我需要新的眼睛来弄清楚我所缺少的是什么?

Line contains ** below, 7th line from the bottom 该行下面包含**,从底部起第7行

I'm getting an error C2660: 'drillOneProblem' : function does not take 3 arguments. 我收到错误C2660:'drillOneProblem':函数没有3个参数。 Help Please! 请帮助!

// 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;
}

Parameters need to be declared in the brackets in function declaration. 参数需要在函数声明的括号中声明。

So this: 所以这:

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

should be this: 应该是这样的:

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

declare your function as 声明你的功能为

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

and remove local variables with same name inside the function 并删除函数内具有相同名称的局部变量

You don't have the parameters in your function declaration (first line) 您的函数声明中没有参数(第一行)

void drillOneProblem()

it should be: 它应该是:

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

you do not have the params in you declaration 您声明中没有参数

 void drillOneProblem()

it should be void drillOneProblem(int c, r1, r2); 它应该是void drillOneProblem(int c,r1,r2);

and you should remove the varriables in you fuc,like that: 并且您应该删除fuc中的变量,如下所示:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误C2660:函数没有2个参数C ++ - Error C2660: function does not take 2 arguments C++ 奇怪的错误c2660“函数不带1个参数” - Strange error c2660 “function does not take 1 arguments” 错误C2660:&#39;Aba :: f&#39;:函数未使用0个参数 - error C2660: 'Aba::f' : function does not take 0 arguments 错误C2660:&#39;MouseListener :: MousePressed&#39;:函数未采用4个参数 - error C2660: 'MouseListener::MousePressed' : function does not take 4 arguments C ++中的特征库给出错误C2660:&#39;Eigen :: MatrixBase <Derived> :: eigenvalues&#39;:函数不带2个参数 - eigen library in C++ gives error C2660: 'Eigen::MatrixBase<Derived>::eigenvalues' : function does not take 2 arguments 简短版本:错误14错误C2660:“ Player :: addSpell”:函数未采用1个参数 - Short version: Error 14 error C2660: 'Player::addSpell' : function does not take 1 arguments 错误 C2660: 'std::allocator<char> ::allocate': function 不占用 2 arguments</char> - error C2660: 'std::allocator<char>::allocate': function does not take 2 arguments 错误 C2660: 'std::pair<a,b> ::pair': function 不带 2 arguments</a,b> - error C2660: 'std::pair<a,b>::pair': function does not take 2 arguments 如何解决“C2660 &#39;SWidget::Construct&#39;:函数不接受 1 个参数”? - How to resolve "C2660 'SWidget::Construct': function does not take 1 arguments"? 尝试在 windows 10 上安装 node-ffi 会出现错误:error C2660: 'v8::FunctionTemplate::GetFunction': function does not take 0 arguments - trying to install node-ffi on windows 10 gives error: error C2660: 'v8::FunctionTemplate::GetFunction': function does not take 0 arguments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM