title: Design Issue (C++)
body: <p>My apologies in advance if I'm not asking this in a right Stack Overflow forum. I'm trying to come up with a design which is easily expandable and also easy to use. So here is my problem:</p>
  
  <p>In C++, I have two classes, called <code>Class One</code> and <code>Class Two</code> which both supports an operation called <code>doSomething(T&amp; data)</code>. <code>T</code> is a <code>struct</code> which for example has two members for <code>Class One</code> and has four members for <code>Class Two</code>. Since I want to enforce <code>doSomething(T&amp; data)</code> into those classes, I have a base class called Base.</p>
  
  <pre><code>template &lt;class T&gt;
  class Base
  {
      typedef T    data_type;
      virtual bool doSomething(data_type&amp; data) const = 0;
  };
  
  struct OneData { int a; int b; };
  class One : public Base&lt;OneData&gt;
  {
      bool doSomething(data_type&amp; data) const { ... }
  };
  
  struct TwoData { int a; float b; int c; char d; };
  class Two : public Base&lt;TwoData&gt;
  {
      bool doSomething(data_type&amp; data) const { ... }
  };
  </code></pre>
  
  <p>One big problem I have with this approach is, I cannot defined a <code>Base</code> type variable. I'm forced to use <code>One</code> or <code>Two</code> as type which forces me to defined 2 variables (what I really want is to create <code>Base</code> type variable and allocate memory or initialize it to <code>One</code> or <code>Two</code> based on the given <code>T</code>).</p>
  
  <p>Furthermore, I was thinking to create class called <code>OneTwo</code> which defines <code>doSomething(T&amp; data)</code> which basically hides the headache of which object to create from clients.</p>
  
  <pre><code>// This is just idea of what I want but don't know how??
  template&lt;class OneT, class TwoT&gt;
  struct OneTwo
  {
      bool doSomething(T&amp; data) const // Here I don't know how to get to T
      {
          if (OneT::owns(data))      // call OneT::doSomething
          else if (TwoT::owns(data)) // call TwoT::doSomething
          else                       // Maybe exception, error, ...
      }
  }; 
  </code></pre>
  
  <p>I'm not sure even if I did right approach on class <code>One</code> and <code>Two</code>. Also, I tried to explain it as clear as possible but please ask if anyone need more information.</p>
  
  <p>Please help me to understand on how to design this?</p>
  
  <p>Thank you, </p>
  
  <hr>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>In nutshell, I want to have minimum of 2 classes (<code>class One and Two</code> in above example) and possibly more that follow same interface such implement same operation (<code>doSomething(...)</code> in above example), but the given data to that operation is different for each class.</p>
  
  <p>Moreover, I want to provide a single interface to all those classes classes (<code>class OneTwo</code> in above example) for ease of use.</p>