A reusable function sometimes needs another function to decide one part of its work. A function passed for that purpose is called a callback. You have seen lambdas supplied to algorithms; a pointer to an ordinary named function is another way to supply behavior.
#include <iostream>
int addTwo(int value) { return value + 2; }
using Adjustment = int (*)(int);
int apply(int value, Adjustment operation) {
if (operation == nullptr) return value;
return operation(value);
}
int main() {
std::cout << apply(5, addTwo) << '\n';
}
Read int (*)(int) from its pieces: this is a pointer (*) to a function taking one int and returning an int. The parentheses around the star matter; they distinguish this type from a function returning a pointer. The alias Adjustment saves repeating that punctuation.
addTwo without parentheses names the function and can convert to its pointer. addTwo(5) calls it immediately and produces an integer instead. Inside apply, operation(value) calls the selected function. A function pointer can also be null, so the example checks before calling it. The fallback returns the input unchanged.
The starter supplies two complete calculations and a safe caller. In apply, the null guard is already complete. Replace the return after it so the selected function computes the answer. In main, selected is a separate function pointer: change which function it names, leaving the later selected(6) call in place. Both named functions have the required signature. This simple pointer type is for free functions like these, not arbitrary member functions or capturing lambdas. It gives the caller one narrow promise: any selected operation accepts an integer and returns an integer.
Edit main.cpp; the supplied Console probes already call your code.
operation(value) after the null guard in apply. Expect Applied: 7; the null callback still returns No callback: 4.selected to the named function doubleValue, without calling it during assignment. Expect Selected: 12.Use Run to inspect the Console, then Submit to check your work.