2017-05-05 107 views
0

我想做一个函数,将“parseUserInput()”和我的计划是通过parseUserInput()的“输入”参数作为参数传递用户的输入。但是,当我将任何东西放入“输入”参数时,出现错误,说明存在“no matching function for call to 'parseUserInput'没有匹配的函数调用'parseUserInput'

什么是导致此错误的原因?

std::string branchCommand; 
std::string userInputCmd; 
std::string parsedInput; 
std::string parseUserInput(); 

std::string inputCommand() { 
    std::cin >> userInputCmd; 
    parseUserInput(userInputCmd); 

    return branchCommand; 
} 

std::string parseUserInput(std::string Input) { 

    return parsedInput; 
} 

回答

0

你宣布parseUserInputstd::string parseUserInput();不允许任何参数。如果你想传递一个参数,那么改变声明以匹配函数调用和函数定义。

string parseUserInput(std::string Input) // declaration 

然后,你可以这样调用:parseUserInput(userInputCmd);

相关问题