I am reading C++ in easy steps and came across a piece of code for references and pointers that I do not understand.
The code is void (* fn) (int& a, int* b) = add;
. As far as I know it does not affect the program itself but would like to know what this code does.
#include <iostream>
using namespace std;
void add (int& a, int* b)
{
cout << "Total: " << (a+ *b) << endl;
}
int main()
{
int num = 100, sum = 200;
int rNum = num;
int* ptr = #
void (* fn) (int& a, int* b) = add;
cout << "reference: " << rNum << endl;
cout << "pointer: " << *ptr << endl;
ptr = ∑
cout << "pointer now: " << *ptr << endl;
add(rNum, ptr);
return 0;
}