title: Initialize 2D array of objects
body: <p>Hi I am having a problem with the initialization of a 2D array of objects.
  The class is   <code>TermFrequency(Key,string,int,double);</code>
  That's how I initialize the dynamic 2D array of objects:</p>
  
  <pre><code>// TermFrequency tfreq [v_word.size()][totalNumberOfDocuments];
     TermFrequency** tfreq = new TermFrequency*[v_word.size()];
     for(size_t i = 0; i &lt; v_word.size(); ++i)
         tfreq[i] = new TermFrequency[totalNumberOfDocuments];
  </code></pre>
  
  <p>I understood why i am getting the error:  </p>
  
  <ul>
  <li>no matching function for call to 'TermFrequency::TermFrequency()'|</li>
  <li>note: TermFrequency::TermFrequency(Key, std::string, int, double)|</li>
  </ul>
  
  <p>I just want to know how I can fix it?</p>
  
  <p>Thank you.</p>
  
  <p>Ok I added the <strong>DEFAULT</strong>  Constructor TermFrequency and it worked:<code>TermFrequency();</code>
  Now for example I can add new objects like, right?</p>
  
  <p>Is that implementation considered right?</p>
  
  <pre><code> For(int i = 0; i &lt; Length1; i++){
      for(int j = 0; j &lt; length2;j++){
         tfreq[i][j] = TermFrequency(v_word[i],documents[j],j,wordCount);
      }
      }
  </code></pre>
  
  <p>And that's for the output:</p>
  
  <pre><code>  for( size_t i = 0 ; i &lt; v_word.size() ; i++ )
      {
          for(int j = 0; j &lt; totalNumberOfDocuments;j++)
          {
               cout &lt;&lt; tfreq[i][j].getTermFrequency() &lt;&lt; endl;
          }
      }
  </code></pre>