How to simulate Func<T1, T2, TResult> in C++?
<p>In C#, I use Func to replace Factories. For example:</p>

<pre><code>class SqlDataFetcher    
{
    public Func&lt;IConnection&gt; CreateConnectionFunc;

    public void DoRead()
    {
        IConnection conn = CreateConnectionFunc(); // call the Func to retrieve a connection
    }
}

class Program    
{
    public void CreateConnection()
    {
        return new SqlConnection(); 
    }

    public void Main()
    {
        SqlDataFetcher f = new SqlDataFetcher();
        f.CreateConnectionFunc = this.CreateConnection;
        ...
    }
}
</code></pre>

<p>How can I simulate the code above in C++?</p>
