title: creating a generic instance of a class template in c++
body: <p>I'm making a template library in c++. I think it needs to be in the form of a template class because it has to be able to store some data.  I would like to be able to create an instance of that class without having to specify a data type. </p>
  
  <p>Here's what the class template would look like</p>
  
  <pre><code>template&lt;class T&gt; 
  class MyTemplateClass{
  public:
       void saveData(T data);
  private:
      T my_data;
  };
  
  template&lt;class T&gt; 
  void MyTemplateClass&lt;T&gt;::saveData(T data){
      //bunch of code goes here
  }
  </code></pre>
  
  <p>and here's how I would like to declare it:</p>
  
  <pre><code>class LibraryUser{
  public:
      void saveDoubleData(double data);
      void saveFloatData(float data);
  private:
      MyTemplateClass&lt;UNKNOWN_TYPE&gt; my_generic_object;
  };
  </code></pre>
  
  <p>and use it:</p>
  
  <pre><code>void LibraryUser::saveDoubleData(double data){
      my_generic_object.saveData(data);
  }
  
  void LibraryUser::saveFloatData(float data){
      my_generic_object.saveData(data);
  }
  </code></pre>
  
  <p>What should UNKNOWN_TYPE be? Is this possible? </p>
  
  <p>EXTRA NOTES: I cannot edit the function prototypes of the <code>LibraryUser</code> class because it is part of an existing plug-in framework. I'd rather not use template specialization because I don't want to double the code in saveData() since it's actually pretty long.</p>