【发布时间】:2014-10-13 18:37:48
【问题描述】:
我正在尝试对此进行调试,但在这里无法找出问题所在。为什么即使我传递了正确的参数,调用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);
【问题讨论】:
-
doubleCoefficient未在该代码示例的任何地方定义。另外,我很少使用 C++,但是那个函数签名合法吗?你能发布确切的错误吗? -
你从哪里得到你在
main中传递给naiveGaussianElimination的doubleCoefficient参数? -
@slugonamission : 我忘了贴在这里。
-
@TylerGaona:我忘记粘贴了。
-
我不相信
naiveGaussianElimination(int, float doubleCoefficient[][count+1])是一个有效的声明。我只需传入一个指向浮点数的指针:naiveGaussianElimination(int, float**)
标签: c++ function multidimensional-array