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...

10 Years
Discussion Span
Last Post by Ancient Dragon
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.