std::function<void(int)> is not a function. It is a class with an operator(). It has a constructor that you need to invoke to create an instance of that class. For example like this:
std::function<void(int)> callback = abc;
On the other hand, here:
int* b = new int(40); int c = *(int *)b;
new int(40) does create an int object and b is a pointer to that object. The cast (int*)b doesn't do anything, because b is already a int* that you can dereference to assign the value of the int to c.
I tried to keep it simple, for a more accurate explanation of what is actually happening in your code I refer you to this answer: https://stackoverflow.com/a/70166958/4117728.
void(*)(int)is astd::function<int>*?int c = *(int *)b;andint c = (int)*b;?