I'm getting an error message saying that there is no matching function for the call to my function (validateData) that i am calling inside of a for loop of another function(inputData), even though i have declared the function and have a definition for the function.
I have gone into a tutor on campus to have them help me with the parameters of the function, and now that the parameters are fixed, the function is not calling when i call it, giving me an error message.
//Declare global constants
const int STUDENTS = 3;
const int NONNUMERIC_INFO = 9;
const int NUMERIC_INFO = 2;
const int COURSES = 3;
const int TESTS_and_CNG = 6;
//Declare function prototypes
void inputData();
void validateData(string nonNumeric1[STUDENTS][NUMERIC_INFO], int numeric1[STUDENTS][NUMERIC_INFO], double numeric2[STUDENTS][COURSES][TESTS_and_CNG], int i);
void validateData(string nonNumeric1[STUDENTS][NUMERIC_INFO], int numeric1[STUDENTS][NUMERIC_INFO], double numeric2[STUDENTS][COURSES][TESTS_and_CNG], int i, int j);
void validateData(string nonNumeric1[][NUMERIC_INFO], int numeric1[STUDENTS][NUMERIC_INFO], double numeric2[STUDENTS][COURSES][TESTS_and_CNG], int i, int j, int k);
inside the main function, it calls the inputData function
//Declaring arrays (inside inputData function definition
string nonNumeric1[STUDENTS][NONNUMERIC_INFO];
int numeric1[STUDENTS][NUMERIC_INFO];
double numeric2[STUDENTS][COURSES][TESTS_and_CNG];
//Outer loop on students
for(int i = 0; i < 3; i++)
{
getline(fin, nonNumeric1[i][1]); //Name
getline(fin, nonNumeric1[i][2]); //ID
fin >> numeric1[i][0]; // Age
fin.ignore();
getline(fin, nonNumeric1[i][3]); //Address
fin >> numeric1[i][1]; //Years
fin.ignore();
getline(fin, nonNumeric1[i][4]); //Phone
getline(fin, nonNumeric1[i][5]); //SSN
validateData(nonNumeric1, numeric1, numeric2, i); //error message here
//Middle loop on course
for(int j = 6; j < 9; j++)
{
getline(fin, nonNumeric1[i][j]); //Course
validateData(nonNumeric1, numeric1, numeric2, i, j); //error here
//Inner loop on tests
for(int k = 0; k < 5; k++)
{
fin >> numeric2[i][j][k]; //Grade
fin.ignore();
validateData(nonNumeric1, numeric1, numeric2, i, j, k); //error here too
numGrade(nonNumeric1, numeric1, numeric2, i, j , k);
letGrade(numeric2, i, j , k);
comments(numeric2, i, j, k);
report(nonNumeric1, numeric1, numeric2, int i, int j, int k);
}
//Function definition
void validateData(string nonNumeric1[][NONNUMERIC_INFO], int numeric1[][NUMERIC_INFO], double numeric2[][COURSES][TESTS_and_CNG], int i)
{
//if statements to validate all data that only uses the i variable
}
void validateData(string nonNumeric1[][NONNUMERIC_INFO], int numeric1[][NUMERIC_INFO], double numeric2[][COURSES][TESTS_and_CNG], int i, int j)
{
//if statements to validate all data that only uses the i and j variables
}
void validateData(string nonNumeric1[][NONNUMERIC_INFO], int numeric1[][NUMERIC_INFO], double numeric2[][COURSES][TESTS_and_CNG], int i, int j, int k)
{
//if statements to validate all data that only uses the i,j and k variables
}
the error message is "error: no matching function for call to 'validateData(std::__cxx11::string [3][9], int [3][2], double [3][3][6], int&')" the error also happens on the other validateData function calls
There's a mismatch between the arguments and parameters.
you declare
string nonNumeric1[STUDENTS][NONNUMERIC_INFO];
void validateData(string nonNumeric1[STUDENTS][NUMERIC_INFO], int numeric1[STUDENTS][NUMERIC_INFO], double numeric2[STUDENTS][COURSES][TESTS_and_CNG], int i);
but call
validateData(nonNumeric1, numeric1, numeric2, i, j); //error here
the parameter expected has a dimension of "NUMERIC_INFO" but you pass in an array of size "NONNUMERIC_INFO"
validdateData func needs string, int, ....
You should declare like this
void validateData(string param1, int param2, double param3, int i);
Your func need not to know your variable looks like.
And you declared your array,
string nonNumeric1[STUDENTS][NONNUMERIC_INFO];
But you tried to call
nonNumeric1[STUDENTS][NONNUMERIC_INFO]
Actually, it's illegal access. That memory is not your assigned array.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.