how to pass a member function as a function pointer?
<p>I want add a logger function to a worker class,
how to pass a member function as a function pointer?
use mem_fun?</p>

<p>here is the code sample:</p>

<pre><code>class Work{
public:
    void (*logger) (const string &amp;s);
    void do_sth(){if (logger) logger("on log")};
};

classs P{
public:
    void log(const string &amp;s)(cout &lt;&lt; s);
};

int main(){
    Work w;
    P p;
    w.logger = &amp;p.log;
    w.do_sth();
}
</code></pre>

<p>edit:</p>

<p>I don't want to use void (P::*xxx)() because it stick to class P...</p>

<p>I know C++ hide sth, the real log function is: void log(P &amp;p, const string &amp;s),</p>

<p>and the real project is like this:</p>

<p>I create a CDialog, and there is a log function, it copy the log string to a CEdit.</p>

<p>So I need pass this log function to a Worker class, this class do some serial port job,</p>

<p>I need log and show the data send and recived...</p>
