Skip to content

Pointers to functions in C++

I need to implements some codes in C++. Just remembering some concepts like pointers to functions.

A simple example:

#include <stdlib.h>
#include <iostream>

using namespace std;

double evalFunction(double (*f)(double), double param){
    return f(param);

double function(double x){
    return x/2;

int main(int argc, char** argv) {
    cout << function(5.0) << endl;
    cout << evalFunction(function, 5.0) << endl;
    return (EXIT_SUCCESS);
Published inenglish

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *