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