struct Name {
        string first_name;
        string mid_name;
        string last_name;
      };
      
      bool operator<(const Name& other) const {
        //before c++11
        return first_name < other.first_name
            || first_name == other.first_name && mid_name < other.mid_name
            || first_name == other.first_name && mid_name == other.mid_name && last_name < other.last_name;
      
        //after c++11
        return std::tie(first_name, mid_name, last_name) < 
            std::tie(other.first_name, other.mid_name, other.last_name);
      }

      Cpp language logocompare string

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.