When I run my program, I get the Segmentation Fault error. I believe it is coming from how I am using the array "string *words" which is privately declared in the class definition. I use it here in the .cpp file anyone know what I need to change? heres the function I think the problem is in:
Dictionary::Dictionary(string filename){
ifstream inF;
inF.open(filename.c_str());
if (inF.fail()){
cerr << "Error opening file" <<endl;
exit(1);
}
inF >> numwords;
numwords = 3000;
words = new string(words[numwords]);
for(int i=0; i <= numwords - 1; i++){
inF >> words[i];
}
inF.close();
}
words = new string(words[numwords])- what is that line supposed to do in your code? What is the purpose ofwords[numwords]on the right-hand side, inside the braces? If you are the author, then I'm sure you should be able to explain why it is written that way.