Cant seem to figure out why I can't pass my function as a parameter and I have to use this program for future programs. By the end of this week I have to not only figure out that problem but convert the struct to a class among other things. Any help would be greatly appreciated... Thank you in advance for any help.
Im not completely sure I understand you. I did call the function and the reason Im using a function as a parameter is to take the return value from the function without creating a separate variable. Although I tried that as well and I couldn't get to work that way either. Are you saying that a user defined function can't be use as a parameter?
As giblit stated: you really don't need the function as a parameter.
You defined it wrong: void printArray_N_store((*file_Sort)(stat_list test_vals3));
-> void printArray_N_store(stat_list (*file_Sort)(stat_list test_vals3));
stat_list file_Sort(stat_list stat_vals2);
void printArray_N_store(const stat_list &sl); // Note: Not the function but result
int main()
{
...
printArray_N_store(file_Sort(stat_vals));
Im sorry guys Im trying all of the things your telling me to the best of my ability and I keep getting the following:
- Im using Visual Studio and Ive even tried on a separate IDE (called EBE) provided by the school and no luck.
This is the first error with the visual studio,
source.cpp(74): error C2664: 'void printArray_N_store(stat_list (__cdecl *)(stat_list))' : cannot convert argument 1 from 'stat_list' to 'stat_list (__cdecl *)(stat_list)'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
There's one detail we need to look at before we define printArray_N_store is the function it takes takes a parameter itself, a stat_list passed by value. So we need to pass that parameter in too, but we'll pass it in by const ref.
Thank you all for your help, I apologize for the late response. Im in the last two week of summer school and they are laying it on thick. Also I have a two year old and five year old, so I don't have much free time. I plan to use your advice tomorrow. Thank you all again.