I try to load less than the sorted list (==) and (& lt;) operator less than I am not sure if I understand that whatever I am doing makes sense. I have a string with string variables for DestinationCity, from which these operators have to compare. I have used strcmp in an effort to do this work here:
bool sortedListClass :: operator & lt; (Const flightRec & amp; rhs) const {if (strcmp (flightrec.DestinationCity, rhs.DestinationCity) & lt; 0) {// I 'm not sure if flightRec.DestionationCity should have written me. Back true; } And false return; } Bool sortedListClass :: operator == (const flightRec and rhs) const {if (strcmp (flightrec.DestinationCity, rhs.DestinationCity) == 0) {back true; } And false return; } Here are the error messages I
sortedListClass.cpp: "bool sortedListClass :: operator <" (const flightRec & amp; Context: sortedListClass.cpp: 185: 25: error: before the expected primary-expression "token"
sortedListClass.cpp: in the member function "bool sortedListClass :: operator == ( Const flightRec & amp;) Concept: sortedListClass.cpp: 194: 28: Error: Expected Primary - Before Expression ???? Line Token
// I'm not sure what flightRec.DestionationCity is me Should write.
You should not :-). If you click on the operator on some class & lt; , you do not do this in the container category, but in the sections you want to compare, here it will be flightRec . bool flightRec :: operator & lt; (Const flightRec and others) {// Compare it and other if (strcmp (this-> destination point, other. DestinationCity))}}
Comments
Post a Comment