Preparing for my internship

Only two more days before my internship starts. I’m a bit nervous and excited to dive into this adventure. Today i decided to fresh my knowledge of (MS)-C++ a bit up. I’ve read a tutorial on function pointers and naming conventions. A couple of weeks ago i already had a look at pointers to member functions.

#include <iostream>
using namespace std;

void customcallback() {
        cout << "running custom callback" << endl;
}

typedef int (*method)(int, int);

int sum(int a, int b) {
        return a + b;
}

method dosum() {
        return &sum;
}

int main() {
        void (*plugin)() = NULL;
        plugin = &customcallback;
        plugin();

        method mymethod = dosum();
        cout << mymethod(10, 4) << endl;

        return 0;
}

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>