<p>I have a function pointer defined by:</p>

<pre><code>typedef void (*EventFunction)(int nEvent);
</code></pre>

<p>Is there a way to handle that function with a specific instance of a C++ object?</p>

<pre><code>class A
{
private:
    EventFunction handler;

public:
    void SetEvent(EventFunction func) { handler = func; }

    void EventOne() { handler(1); }
};

class B
{
private:
    A a;
public:
    B() { a.SetEvent(EventFromA); }  // What do I do here?

    void EventFromA(int nEvent) { // do stuff }
};
</code></pre>

<p><strong>Edit:</strong> Orion pointed out the options that Boost offers such as:</p>

<pre><code>boost::function&lt;int (int)&gt; f;
X x;
f = std::bind1st(
      std::mem_fun(&amp;X::foo), &amp;x);
f(5); // Call x.foo(5)
</code></pre>

<p>Unfortunately Boost is not an option for me.  Is there some sort of "currying" function that can be written in C++ that will do this kind of wrapping of a pointer to a member function in to a normal function pointer?</p>

Unfortunately, the EventFunction type cannot point to a function of B, because it is not the correct type. You could make it the correct type, but that probably isn't really the solution you want:
```
typedef void (*B::EventFunction)(int nEvent);
```
... and then everything works once you call the callback with an obhect of B. But you probably want to be able to call functions outside of B, in other classes that do other things. That is sort of the point of a callback. But now this type points to something definitely in B. More attractive solutions are:
Make B a base class, then override a virtual function for each other class that might be called. A then stores a pointer to B instead of a function pointer. Much cleaner.
If you don't want to bind the function to a specific class type, even a base class (and I wouldn't blame you), then I suggest you make the function that gets called a static function: "
```
static void EventFrom A(int nEvent);
```
". Then you can call it directly, without an object of B. But you probably want it to call a specific instance of B (unless B is a singleton).
So if you want to be able to call a specific instance of B, but be able to call non-B's, too, then you need to pass something else to your callback function so that the callback function can call the right object. Make your function a static, as above, and add a void* parameter which you will make a pointer to B.
In practice you see two solutions to this problem: ad hoc systems where you pass a void* and the event, and hierarchies with virtual functions in a base class, like windowing systems