#include <iostream>
// Using Function Pointers
// Callback function
void myCallback(int x) {
std::cout << "myCallback() - Callback called with value: " << x << std::endl;
}
// Function that accepts a callback
void process(int value, void (*callback)(int)) {
std::cout << "process() - Processing value: " << value << std::endl;
callback(value); // invoke callback
// Call → means to execute a function.
// Back → means the control of execution will return back to the main function later, after some other work is done.
}
int main() {
process(234, myCallback); // pass function pointer
std::cout << "after";
}
/*
run:
process() - Processing value: 234
myCallback() - Callback called with value: 234
after
*/