title: Design a good C++ wrapper class that wraps around multiple functionalities
body: <p>I want to design a wrapper class in C++ that implements File transfer using FTP, SFTP. </p>
  
  <p>I have a base class <code>FileTransfer</code> (using curl) that is inherited by derived class <code>FTP</code>. I need to support SFTP, so I have implemented another derived class <code>SFTP</code> that also inherits from <code>FileTransfer</code>.</p>
  
  <p>I am making a wrapper class code along the following lines. However, this doesn't look like good design. I am relatively new to OOP, although I have worked on C in the past.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>class Wrapper {
    public:
    Wrapper(int m_protocol){
      protocol = m_protocol;
      if (protocol)
        pftp = new FTP();
      else
        psftp = new SFTP();
    }
    
    ~Wrapper() {
      if (protocol)
        delete pftp;
      else
        delete psftp;
    }
    //Function supported by both ftp/sftp
    void do_something(){
      if (protocol)
        pftp-&gt;do_something();
      else 
        psftp-&gt;do_something();
    }
    
    //FTP specific function
    void use_passive(){
      assert(protocol);
      pftp-&gt;use_passive();
    }
    
    //SFTP specific function
    void ssh_key(){
      assert(!protocol);
      psftp-&gt;ssh_key();
    }
    
    private:
     int protocol;
     FTP *pftp;
     SFTP *psftp;
  };</code></pre>
  </div>
  </div>
  </p>
  
  <p>How can I improve this design? How can I avoid the <code>if (protocol)</code> check inside every function and improve the code quality? Should I instead use <code>void</code> pointers for <code>psftp</code> and 'pftp`?</p>
  
  <p>Edit: I am using a wrapper because at a lot of places in the project, existing FTP object is being used and if I use a separate class for SFTP (without a wrapper), I will have to add an <code>if</code> check every time to also support SFTP. I don't want to expose the detail (FTP/SFTP) to the caller.</p>