title: Changing a Template argument c++
body: <p>I have created a dynamically expanding container class using template.
  But this can only store objects of same datatype.
  How can i create a container class that expands dynamically and can hold objects of types specified when expanding the class.</p>
  
  <p>That is for eg:-</p>
  
  <p>if obj is an object of said class
  I should be able to call a function say</p>
  
  <pre><code>obj.foo&lt;int&gt;(25);
  </code></pre>
  
  <p>and after that the same function to store second member as a Boolean type or float</p>
  
  <pre><code>obj.foo&lt;bool&gt;(true);
  </code></pre>
  
  <p>is there any way to do this I have thought about templates but I cannot set a class member without knowing the datatype before hand</p>