yeah, it runs the program, but it ends up giving me a debug error after i try to input words that replace specific words within the paragraph in the stream. (such as animal, place, noun1, etc...)
return replaceWith;
that's what i changed it too, but of course it isn't right. don't think, to be perfectly honest with you, i was ever taught specifically about this. anyway to get some more help from you guys? seems this is the last thing i need to do before the program works
Sorry, we seem to be in different time zones. For me, you write your posts at 4am.
i think you want to replace all words mathing "toReplace" with "replaceWith". It makes no sense to set toReplace = replaceWith and returning it then ..
try something like this:
1 2 3 4 5 6
void Paragraph::replaceWord(string toReplace, string replaceWith)
{
for (int i = 0; i < wordCount; i++) // wordCount is a private member
if (toReplace == words[i]) // go through all words and check if it matches toReplace
words[i] = replaceWith; // if yes, set it to replaceWith
}
Normally if you use objects of more complex classes which you do not change in a function you do something like this:
Error 1 error C2556: 'void Paragraph::replaceWord(std::string,std::string)' : overloaded function differs only by return type from 'std::string &Paragraph::replaceWord(std::string,std::string)' f:\advancedc++\project 6 (bad libs) chris nelson\bad libs project\main.cpp 208
Error 2 error C2040: 'Paragraph::replaceWord' : 'void (std::string,std::string)' differs in levels of indirection from 'std::string &(std::string,std::string)' f:\advancedc++\project 6 (bad libs) chris nelson\bad libs project\main.cpp 208