C++ program to illustrate pointer to a function

#include<iostream>

using namespace std;

void (*ptr)(int);

void change(int);

 

void change(int a)

{

      a++;

      cout<<endl<<a;

}

 

int main()

{

     ptr=change;

     (*ptr)(10);

     return 0;

}

Output

11

Leave a Reply

Your email address will not be published.