I have a code as below
// pointer to functions

#include <iostream>
using namespace std;

int addition (int a, int b)
{ return (a+b); }

int subtraction (int a, int b)
{ return (a-b); }

int operation (int x, int y, int (*functocall)(int,int))
{
  int g;
  g = (*functocall)(x,y);
  return (g);
}

int main ()
{
  int m,n;
  int (*minus)(int,int) = subtraction;

  m = operation (7, 5, addition);
  n = operation (20, m, minus);
  cout <<n;
  return 0;
}

In the assigment,
g = (*functocall)(x,y);
what actually happens. Is it a function call. In that case functocal is a pointer to fuction. It will point to either addition or subtraction function
I am confused about function calls. What actually happens in function call.
Here the address of the function to be called is in the in functocall and does the above statement acts as function call? If that is the case then how a function call occurs by having the address of the function in that variable? I want to know if that statement causes a function call what actually happens internally? please help me...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.