title: Insert object to vector in alphabetical order c++
body: <p>My goal is to make simple function that would insert objects to vector by keeping it alphabeticaly sorted so i can later easely search in vector.</p>
  
  <p>This is my simplified example:</p>
  
  <pre><code>#include &lt;cstdio&gt;
  #include &lt;cstdlib&gt;
  #include &lt;cmath&gt;
  #include &lt;cstring&gt;
  #include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  using namespace std;
  
  class Names {
  public:
      Names(void);
      ~Names(void);
      bool Insert(const string &amp; namer);
  private:
  
      struct Person {
          string name;
      };
      vector&lt;Person&gt;people;
  };
  
  Names::Names() {
  };
  
  Names::~Names() {
  };
  
  bool Names::Insert(const string&amp; namer) {
      Person p;
      p.name = namer;
      people.insert(upper_bound(people.begin(), people.end(), p), p);
  }
  
  int main(int argc, char** argv) {
      Names b1;
      bool status;
      status = b1 . Insert("John Smith");
      status = b1 . Insert("Bat Man");
      status = b1 . Insert("A Aron");
      return 0;
  }
  </code></pre>
  
  <p>It doesnt work probably because upper_bound function cant compare string. Can anyone help me how to properly use insert function to insert into right spot ?</p>
  
  <p>Thank you for any help.</p>
  
  <p>Edit:</p>
  
  <p>My problem is that my solution does not work because problems with compilation and i would like to find out why.</p>