C++ 错误:参数太少,无法运行
我知道有很多类似的问题,但我太新了。所以我的问题是,我必须做一个makefile并编译我的项目,但在某个时候它会返回错误 Main.cppC++ 错误:参数太少,无法运行,c++,compilation,C++,Compilation,我知道有很多类似的问题,但我太新了。所以我的问题是,我必须做一个makefile并编译我的项目,但在某个时候它会返回错误 Main.cpp #include <iostream> #include <stdlib.h> #include "SquareRootCalculation.h" using namespace std; int main(int argc, char* argv[]) { int number = atoi(argv[0]); i
#include <iostream>
#include <stdlib.h>
#include "SquareRootCalculation.h"
using namespace std;
int main(int argc, char* argv[])
{
int number = atoi(argv[0]);
int th = atoi(argv[1]);
float result = SquareRoot(number, th);
return 0;
}
和sqrtcalc.h
int SquareRoot(int number, int th);
还有一个生成文件
all:
g++ Main.cpp InitialGuess.cpp SquareRootCalculation.cpp -o FR
它返回一个错误
InitialGuess.h 1 In function 'int SquareRoot (int,int,float)'
InitialGuess.h "too few arguments 'int InitialGuess(int, float)'
此时的SqrtCalc 7错误是不言自明的: 在您定义的.h文件中
int InitialGuess(int number,float y)代码>-有2个参数,但在.cpp文件int InitialGuess(int number)
-中有一个参数
与平方根
函数相同的问题这是函数的声明:
int SquareRoot(int number, int th, float y)
这就是你所说的:
SquareRoot(number, th);
你错过了第三个论点
此外,InitialGuess
接受两个参数,但只有一个
InitialGuess.h 1 In function 'int SquareRoot (int,int,float)'
InitialGuess.h "too few arguments 'int InitialGuess(int, float)'
int SquareRoot(int number, int th, float y)
SquareRoot(number, th);