2013-10-14 2 views
-3

비슷한 질문이 많이 있음을 알고 있지만 너무 새롭습니다. 그래서 내 문제는 내가 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]); 
    int th = atoi(argv[1]); 
    float result = SquareRoot(number, th); 
return 0; 
} 

InitialGuess.cpp

#include <iostream> 
#include <math.h> 
using namespace std; 
int InitialGuess(int number) 
{ 
    float numberLength = 0; 
for(; number != 0; number /= 10, numberLength++); 
float n = nearbyint(sqrt(numberLength)); 
float y = numberLength * pow(10, n); 
return 0; 
} 

SqrtCalc.cpp

#include <iostream> 
#include "InitialGuess.h" 
#include <math.h> 
using namespace std; 
int SquareRoot(int number, int th, float y) 
{ 
int initialGuess = InitialGuess(y); 
float x = initialGuess; 
for (int k=1; k< th; ++k) 
    { 
     x = (x + (number/x))/2; 
    } 
cout<<x;  
return 0; 
} 

도 나는 InitialGuess.h

int InitialGuess(int number, float y); 
이 1,515,

및 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 에러를 반환

답변

1

오류 자명하다 :

당신이 int InitialGuess(int number, float y);을 정의 .H 파일

-2 인수,하지만 .cpp 파일 int InitialGuess(int number)에 - 하나

SquareRoot 기능

2

와 같은 문제와이 함수의 선언입니다 :

int SquareRoot(int number, int th, float y) 

이 당신이 그것을 호출하는 방법이다 : 당신은 t을 놓치고

SquareRoot(number, th); 

을 그는 세 번째 주장이다.

또한 InitialGuess은 두 개의 인수를 취하지 만 하나만 갖고 있습니다.

관련 문제