title: How do sets differentiate between objects?
body: <p>How does a set differentiate between objects in both Java and C++? Or do sets not differentiate them at all?</p>
  
  <p>Take these for example:<br>
  <strong>C++</strong></p>
  
  <pre><code>std::set&lt;A&gt; aset;
  A a(1, 2); // Assume A has only two elements, and this constructor sets them both
  aset.insert(a);
  A a2(1, 2); // This would initialise a `A' object to the same values as `a', but a different object
  aset.count(a2); // Would this return 1 or 0?
  </code></pre>
  
  <p><strong>Java</strong></p>
  
  <pre><code>set&lt;A&gt; aset;
  A a = new A(1, 2); // Assume A has only two elements, and this constructor sets them both
  aset.add(a);
  A a2 = new A(1, 2); // This would initialise a `A' object to the same values as `a', but a different object
  aset.contains(a2); // Would this return true or false?
  </code></pre>