title: How can I declare a template pointer without knowing the type?
body: <p>This is what I would like to do:</p>
  
  <pre><code>ExampleTemplate* pointer_to_template;
  cin &gt;&gt; number;
  switch (number) {
  case 1:
      pointer_to_template = new ExampleTemplate&lt;int&gt;();
      break;
  case 2:
      pointer_to_template = new ExampleTemplate&lt;double&gt;();
      break;
  }
  pointer_to_template-&gt;doStuff();
  </code></pre>
  
  <p>This doesn't compile because the template type must be specified when declaring the pointer. (<code>ExampleTemplate* pointer_to_template</code> should be <code>ExampleTemplate&lt;int&gt;* pointer_to_template</code>.) Unfortunately, I don't know the type of the template until it's declared in the switch block. What is the best work around for this situation?</p>