Function Pointer and callback in C plus plus programming language

Function Pointer and callback in C plus plus programming language

Instructor-svgAl-Mamun Sarkar
Apr 03 , 2020

Function Pointer and callback in C plus plus programming language. The following code shows the use of function pointer and callbacks in C plus plus Programming Language.

 

Code:

#include<iostream>
using namespace std;

void A()
{
    cout << "Hello";
}

void B(void (*ptr)())
{
    ptr();
}

int main()
{
    B(A);
    return 0;
}

 

Output:

Hello

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram