title: Passing template class as parameter
body: <p>How do I pass a templated class to the constructor of another class? I am trying to pass a templated hash table class to a menu class which will allow me to then allow the user to decide the type of the hash table.</p>
  
  <pre><code>template &lt;class T&gt;
  class OpenHash 
  {
  private: 
      vector &lt;T&gt; hashTab;
      vector &lt;int&gt; emptyCheck;
      int hashF(string);
      int hashF(int);
      int hashF(double);
      int hashF(float);
      int hashF(char); 
  
  public:
      OpenHash(int);
      int getVectorCap();
      int addRecord (T);
      int sizeHash();
      int find(T);
      int printHash();
      int deleteEntry(T);
  };
  
  template &lt;class T&gt;
  OpenHash&lt;T&gt;::OpenHash(int vecSize)
  {
      hashTab.clear();
      hashTab.resize(vecSize);
      emptyCheck.resize(vecSize);
      for (int i=0; i &lt; emptyCheck.capacity(); i++)   
      {
          emptyCheck.at(i) = 0;
      }
  }
  </code></pre>
  
  <p>So I have this class Open hash that is templated, because it supposed to allow for any type to be added, I have this working if initiate a object of it in my main and change input types etc. </p>
  
  <pre><code>int main () 
  {
     cout &lt;&lt; "Please input the size of your HashTable" &lt;&lt; endl;
     int vecSize = 0;
     cin &gt;&gt; vecSize;
     cout &lt;&lt; "Please select the type of you hash table integer, string, float, "
             "double or char." &lt;&lt; endl;
     bool typeChosen = false; 
     string typeChoice; 
     cin &gt;&gt; typeChoice;
  while (typeChosen == false)
  {
      if (typeChoice == "int" || "integer" || "i")
      {
          OpenHash&lt;int&gt; newTable(vecSize);
          typeChosen = true;
      }
      else if (typeChoice == "string" || "s")
      {
          OpenHash&lt;string&gt; newTable(vecSize);
         hashMenu&lt;OpenHash&gt; menu(newTable);
          typeChosen = true;
  
      }
      else if (typeChoice == "float" || "f")
      {
          OpenHash&lt;float&gt; newTable(vecSize);
          typeChosen = true; 
      }
      else if (typeChoice == "double" || "d")
      {
          OpenHash&lt;double&gt; newTable(vecSize);
          typeChosen = true;
      }
      else if (typeChoice == "char" || "c" || "character")
      {
          OpenHash&lt;char&gt; newTable(vecSize);
          typeChosen = true; 
      }
      else 
      {
          cout &lt;&lt; "Incorrect type";
      }
  }
  return 0;
  }
  </code></pre>
  
  <p>In my main I want to ask the user what type they which to make the hash table. depending what they enter it should create a instance of this class with the type they want and then pass this to another class called menu which should allow them to call functions from the hash class.</p>