title: What are the default comparison operators for objects?
body: <p>I found a bug in my code where I forgot to use a custom comparator when sorting a container of structs. This made me wonder what it was using as the less than operator, since I didn't define any for the struct.</p>
  
  <p>How do objects compare &lt;, >, and == when those operators aren't defined? Is it by memory address? Is it defined in the standard? I couldn't find any of this information on Google.</p>
  
  <p>EDIT:</p>
  
  <p>Here's the class that I was using:</p>
  
  <pre><code>using namespace std;
  
  typedef unsigned id;
  
  class LogEntry {
      id master_id;
      string timestamp;
      string category;
      string message;
      string str_rep;
  
  public:
      LogEntry(id id, string t, string c, string m) :
              master_id(id), timestamp(t), category(c), message(m) {
      }
  
      string get_timestamp() const {
          return timestamp;
      }
  
      string get_category() const {
          return category;
      }
  
      string get_message() const {
          return message;
      }
  
      string to_string() {
          ostringstream ss;
          ss &lt;&lt; master_id &lt;&lt; "|" &lt;&lt; timestamp &lt;&lt; "|" &lt;&lt; category &lt;&lt; "|"
                  &lt;&lt; message;
          return ss.str();
      }
  
      id get_id() const {
          return master_id;
      }
  };
  </code></pre>
  
  <p>EDIT2: </p>
  
  <p>I realized I made a dumb mistake. I was storing a vector of pointers to the objects. Thus, it's very likely that the pointers are compared by the address. If I hadn't been storing pointers, I don't think it would have compiled.</p>
  
  <p>EDIT3:
  KerrekSB posted a related interesting link in the comments of his answer that is related: <a href="https://stackoverflow.com/questions/13380063/how-can-pointers-be-totally-ordered">How can pointers be totally ordered?</a></p>