2014-10-13 2 views
-2

디버깅을 시도하고 있지만 여기에서 문제를 파악할 수 없습니다. 올바른 매개 변수를 전달 했는데도 naiveGaussianElimination에 대한 호출에 대해 일치하는 함수가 없다고 말하는 이유는 무엇입니까?함수에 맞는 함수가 없습니다.

void naiveGaussianElimination(int count,float doubleCoefficient[][count+1]){ 

} 

int main() { 

/* 
Read from file and assign values to vector 
*/ 

//File stream object 
ifstream inputFile; 

// store file name 
string fileName; 

// ask user for the file name and store it 
cout << "Enter the file name:>> "; 
cin >> fileName; 

//Open the txt file 
inputFile.open(fileName.c_str()); 

//search for the text file 
if(!inputFile.is_open()) 
{ 
    cerr << "Error opening file \n"; 
    exit(EXIT_FAILURE); 
} 
else 
{ 
    cout << "File found and successfully opened. \n"; 
} 

/* 
find the number of variables in the equation 
*/ 
int count =0; 
string line; 
while (getline(inputFile, line)){ 

    count++; 
} 
// 2D array to store augmented matrix 
float doubleCoefficient [count][count+1]; 

/* 
assign values from text file to 2D array 
*/ 
float value; 
while(!inputFile.eof()){ 
    for (int i=0; i<count; i++) { 
     for (int j=0; j<(count+1); j++) { 
      inputFile >> value; 
      doubleCoefficient[i][j]=value; 

     } 
    } 

} 

// invoke naiveGaussianElimination function 
    naiveGaussianElimination(count,doubleCoefficient); 
+0

가 'doubleCoefficient' 어디에도 해당 코드 샘플에 정의되지 않은 증강 매트릭스를 저장한다. 또한, 나는 C++을 많이 사용하지 않지만 함수 서명은 합법적입니까? 정확한 오류를 게시 할 수 있습니까? – slugonamission

+0

'main'에서'naiveGaussianElimination'으로 넘겨주는'doubleCefficient' 인자는 어디서 얻고 있습니까? –

+0

@slugonamission : 여기에 붙여 넣는 것을 잊었습니다. – Sooner

답변

0

** 동적

// 동적 2D 어레이 배열 **

float **doubleCoefficient = new float*[count]; 
    for (int i=0; i<(count+1); i++) { 
     doubleCoefficient[i] = new float[count+1]; 
    } 
} 
2

컴파일러는 다음과 같이 시도 count 여기

void naiveGaussianElimination(int count,float doubleCoefficient[][count+1]) 
                    ^

무엇인지 모르기 때문에 당신이 (1 스크립트 제외) 다차원 배열의 선언에 명시 적 값을 제공해야합니다

void naiveGaussianElimination(int count,float doubleCoefficient[][4]){ 
     ..... 
    } 

자세한 내용 확인 : here

관련 문제