Hi, I'm working on a dictionary where the user inputs a word and the program looks up it's definition.
I'm using a vector to store each Word class.
I cannot get the code to return it's definition however, as I need to overload the operator "==".
Main:
cout << "Enter a word.";
cin >> wordName;
int vecNum =0;
int vecMax = wordVector.size();
while (vecNum <= vecMax) {
if (wordName == wordVector[vecNum].getWord) {
cout << wordVector[vecNum].getDef;
}
else {
cout << "Word does not exist.";
}
}
friend bool operator== (const Word &w1, const Word &w2);
private:
string wordName, def, type;
};
bool operator== (const Word &w1, const Word &w2)
{
return w1.wordName == w2.wordName;
}
#endif
Errors:
C2679 binary'==': no operator found which takes a right-hand operand of type 'overloaded-function'
C3867 'Word::getWord' non-standard syntax; use '&' to create a pointer to member
C3867 'Word::getDef'
Sorry if the post comes out weird. First time using the forum and it's bugging out on me.
LNK1169 one or more multiply defined symbols found
LNK2005 "bool __cdecl operator==(class Word const &,class Word const &)" (??8@YA_NABVWord@@0@Z) already defined in mySearch.obj
Where FileTasker is just a namespace for other functions and mySearch is the current main function.