A callback is any executable code that is passed as an argument to other code, which is expected to call back (execute) the argument at a given time [Source : Wiki]. In simple language, If a reference of a function is passed to another function as an argument to call it, then it will be called as a Callback function.
In C, a callback function is a function that is called through a function pointer.
Below is a simple example in C to illustrate the above definition to make it more clear:
I am function A
In C++ STL, functors are also used for this purpose.
This article is contributed by Ranju Kumari. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Arrow operator -> in C/C++ with Examples
- return statement in C/C++ with Examples
- size of char datatype and char array in C
- Logical Not ! operator in C with Examples
- C++ Program to Illustrate Trigonometric functions
- fill_n() function in C++ STL with examples
- fill() function in C++ STL with examples
- iomanip setbase() function in C++ with Examples
- iomanip setpricision() function in C++ with Examples
- iomanip setiosflags() function in C++ with Examples
- iomanip setfill() function in C++ with Examples
- iomanip setw() function in C++ with Examples
- iomanip resetiosflags() function in C++ with Examples
- Difference between C and C#
Improved By : Subhajit Mandal