Line 1: stdafx.h is generated by a Visual Studio Wizard. You could just remove this line when compiling in a different environment.
Line 2: Defined standard C++ i/o methods
Line 4: Prototype for f1. f1 takes an array of doubles and an int as arguments and returns a pointer to a double.
Line 5: Prototype for f2. f1 takes an array of doubles and an int as arguments and returns a pointer to a double.
Line 5: Prototype for f3. f1 takes a pointer to a double and an int as arguments and returns a pointer to a double.
It should be noted that the actual functions do
not match the prototypes! So really, this code isn't quite right. However, arrays in C and C++ are passed as address of the first element. So they all resolve to passing a pointer to a double for that first parameter. Tricky and seemingly wrong, but that's the way it is. Of course, there's a reason for everything.
http://www.cplusplus.com/forum/general/70081/#msg373940
Line 11: declare an array of 3 doubles.
Line 12: declare a pointer p1 that points to a fuinction that takes a pointer to a double and an int and returns a pointer to a double. Initialise it with the address of function f1.
Line 13: declare a pointer p2 that points to a fuinction that takes a pointer to a double and an int and returns a pointer to a double. Initialise it with the address of function f2.
Line 16: Call the function whose value is in p1 (that is f1) twice. Print the pointer returned on the first call, and dereference that pointer to print the double on the second call.
Line 17: Call the function whose value is in p2 (that is f2) twice. Print the pointer returned on the first call, and dereference that pointer to print the double on the second call.
Line 19: Declare an array of 3 pointers to functions that take a pointer to a double and an int and returns a pointer to a double. Initialise it with the address of functions f1, f2, f3.
It's all quite repetitive from here, so I'll stop unless you're stuck on a particular line.
You said this came from the C++ Primer? Wow, what was Stan Lipman thinking?