I read a half-dozen forum threads relating to this error and most were due to a string declaration and the rest were not relevant to this issue.
This error is in a program that takes on input string, compares it to a list of strings then returns the strings that are close matches. That simple explanation is the gist, the actual implementation is has a bit more to it.
In a test implementation that compiled and works, I used this line of code
Set<Lexicon::CorrectionT> matches = lex.suggestCorrections(line, maxDistance);
Set is a class (uses a bst class) I am reusing from a CS106B course and Lexicon is another class from the course that I wrote and am now reusing for an unrelated project. The function suggestCorrections takes a string line and an edit distance to then compare the string and returns a Set of suggestions.
I revised the line to this
matchSet.corrections = lex.suggestCorrections(matchSet);
by defining a CorrectionT corrections within a Lexicon::MatchesT matchSet and defining matchSet in a preceding function and then passing it as a reference. MatchesT contains the fields for line and maxDistance.
From my knowledge these two lines of code are identical with the exception of the approach I am using.
So, why do I get this error “error C2679: binary ‘=’ : no operator found which takes a right-hand operand of type ‘Set'”
Nope, they are completely different; one instantiates a new object, calling the copy constructor of
Set<Lexicon::CorrectionT>; the other copies the object on the right to the (already created) object on the left, calling the assignment operator, which, for some reason, isn’t available.Has it been implemented in
Set<>? What type ismatchSet.correctionsand what return type hassuggestCorrections?