C++ - Alphabetizing Strings -
i reading information input file. of information, there name. information read struct. there array of these structs.
i need alphabetize structs last name, using binary search tree.
do need write operator overload function ==, <, , >. if can me started on that?
operator overloads work functions or methods.  return type , arguments in same way.  instance, binary operator (like <) member function 1 argument or free function two, 1 each each side of operator.  thing that's different instead of having identifier function name, use special syntax, keyword operator followed operator being overloaded.  if wanted have comparable type, way:
class myusertype {   private:     std::string sort_significant;     std::string sort_insignificant;   public:     bool operator<(const myusertype &) const; };  bool myusertype::operator<(const myusertype & other) const {    return sort_significant < other.sort_significant; } 
Comments
Post a Comment