First and foremost, I apologize as I am a total noob to C++. I am trying to figure out if I am able to, and how to send an array of structs into a function as a parameter. The employee variable is a struct. I currently have the entire function as:
void arraySort(struct Employee *employee[])
{
bool flag = false;
for(int i = 0; i < 5000; i++)
{
int empID1 = employee[i]->empID;
int empID2 = employee[i+1]->empID;
flag = Employee().compareEmpID(empID1, empID2);
if (flag == true) {
Employee swap;
swap = *employee[i+1];
*employee[i] = *employee[i+1];
*employee[i+1] = swap;
}
}
}
Which calls this function:
bool Employee::compareEmpID(int empID1, int empID2)
{
if (empID1 >= empID2)
return true;
return false;
}
I am trying to invoke a call to the arraySorts function from main by using the employee array struct as a pointer:
arraySort(*employee);
Aucun commentaire:
Enregistrer un commentaire