Each time I call the force function I get an undefined reference; collect2: error: ld returned 1 exit status.
Here is the declaration of the force function above the main function in main.cpp:
void force(Particle(&a_p)[SIZE], void(*force_func)(Particle&, Particle&));
Here is the main function in main.cpp:
int main() {
Particle a_particle[SIZE];
for (int i = 0; i++ < iterations;) {
force(a_particle, float3::graviton);
force(a_particle, float3::photon);
}
return 0;
}
Here is the definition of the force function below the main function in main.cpp:
void force(Particle(&a_p)[SIZE], void (*force_func)(const Particle&, const Particle&)) {
for (unsigned int i = 0 ; i++ < SIZE - 1;)
for (unsigned int j = i + 1; j++ < SIZE; ) {
force_func(a_p[i], a_p[j]);
}
}
SIZE is a definition used for the size of the a_particle array and it's uses (Mine is set to 10).
Both float3 and Particle are structs declared in separate header files.
I tried initializing the function pointers separately as variables and passing them onto the function but that also did not work. Could anyone help me find why I still get this error?
If I am missing any required information I am happy to give more.
constkeyword. Just copy & paste and compare the function parameters on neighbor lines.main.cppin one code block.