This is from C++ Primer 5th edition excercise 6.54 and 6.55.
So the first excercise goes like this:
Write a declaration for a function that takes two int parameters and returns an int, and declare a vector whose elements have this function pointer type.
I believe I managed to do the first excercise, but I am not sure since the next exercise, which I dont have a clue what to do with, is a followup on the first excercise.
This is how I declared my vector, I have some doubt whether this is correct or not..Code:using PF = int(*)(int*, int); vector<PF> ivec;
The next exercise:
Write four functions that add, subtract, multiply, and divide two int values. Store pointers to these values in your vector from the previous exercise.
Writing the functions are E-Z-P-Z lemon squeezy, but the next part in storing pointers to these values in the vector is killing me.
I think part of the problem is that I maybe have an incorrect type for the vector. I have tried to just declare pointers to each function, and use each pointer in the vector, but then I think I had to set the type for the vector to int, which I believe is wrong?
Anyway, any help is much appreciated.