title: Comparing strings using std::string::compare, c++
body: <p>I have a question:</p>
  
  <p>Let's say there are two <code>std::string</code>s and I want to compare them, there is the option of using the <code>compare()</code> function of the <code>string</code> class but I also noticed that it is possible using simple <code>&lt; &gt; !=</code> operators (both of the cases are possible even if I don't include the <code>&lt;string&gt;</code> library).
  Can someone explain why the <code>compare()</code> function exists if a comparison can be made using simple operators?</p>
  
  <p>btw I use Code::Blocks 13.12
  here is an example of my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using std::cin;
  using std::cout;
  using std::endl;
  using std::string;
  using std::getline;
  
  int main()
  {
      string temp1, temp2;
      cout &lt;&lt; "Enter first word: ";
      getline (cin,temp1);
      cout &lt;&lt; "Enter second word: ";
      getline (cin,temp2);
      cout &lt;&lt; "First word: " &lt;&lt; temp1 &lt;&lt; endl &lt;&lt; "Second word: " &lt;&lt; temp2 &lt;&lt; endl;
      if (temp1 &gt; temp2)
      {
          cout &lt;&lt; "One" &lt;&lt; endl;
      }
      if (temp1.compare(temp2) &lt; 0)
      {
          cout &lt;&lt; "Two" &lt;&lt; endl;
      }
      return 0;
  }    
  </code></pre>