title: Inputting elements of unknown type into a vector
body: <p>I'm working on a program that takes elements from a user and sorts them. For this program, I have to use a vector as the size of the element list is unknown prior to user input. Our instructions were:</p>
  
  <blockquote>
    <p>Write a program in C++ to implement sorting of a list of elements.
    Elements can be of any type but will all be of same type, like all
    integers or all floats or all chars or all strings (strings shall be
    sorted like in a dictionary). You can implement any sorting algorithm
    of your choice.</p>
    
    <ol>
    <li>Ask the user how many elements will be there</li>
    <li>Ask the user to input elements</li>
    <li>Ask the user to choose the sorting order: ascending or descending or both</li>
    <li>Print both input and output lists</li>
    <li>User will not provide any information regarding the type of elements</li>
    </ol>
  </blockquote>
  
  <p>I'm not very familiar with vectors (teacher basically skimmed topic in class) and my book isn't giving me a whole lot of information on the subject. The problem I'm running into is that I don't know the type of the element list until the user begins input. So far, I have tried:</p>
  
  <ul>
  <li>creating a void type vector (obviously not allowed now that I've researched it, oops)</li>
  <li>overloading a function called <code>insertInVector</code> by sending the first element to the function and letting the function determine which vector type to create based on the type of the first element (which seemed like my best option when I thought of it, except I need access to the vector after the function terminates, so that ended up being a no go, too)</li>
  <li><code>#include &lt;typeinfo&gt;</code> in program, finding the type of the first element, and then
  creating a vector using <code>vector&lt;typeid(firstElement).name()&gt;</code> and honestly I'm not
  sure why that didn't work, but it didn't.</li>
  </ul>
  
  <p>Like I said I have EXTREMELY limited experience with vectors as this is my first time using them. I'm also a fairly new programmer so a lot of the research I've done on this has gone over my head. Any help that could be given in this would be GREATLY appreciated!</p>