C++ syntax: function calling within a class

10 Jul 2010

I've been coddled by lazier languages for so long that I can't believe how much c++ I've forgotten...

I'm trying to make a class that calls a function at a later time. I have something that looks like this:

class SimpleClass{
public:

    SimpleClass(){}
    
    void start(void (*fn)()){
        actionFunction = fn;
    }
    
    void trigger(){
        actionFunction();
    }
 
private:
    FunctionPointer actionFunction;

};  

I get a compile error on the trigger() function:

"Call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type (E980)"

My question: What do I need to do in trigger() to call the function passed in start()?  Everything that makes sense to me returns more errors.

11 Jul 2010

Never mind.  In my sleepy haste I realized I was using the FunctionPointer type and simply needed to .attach() and .call() the function to get it working right.