title: Best Practice : How to get a unique identifier for the object
body: <p>I've got several objects and need to generate a unique identifier for them which will not be changed/repeated during the lifetime of each object.</p>
  
  <p>Basically I want to get/generate a unique id for my objects, smth like this</p>
  
  <pre><code>int id = reinterpret_cast&lt;int&gt;(&amp;obj);
  </code></pre>
  
  <p>or </p>
  
  <pre><code>int id = (int)&amp;obj;
  </code></pre>
  
  <p>I understand the codes above are bad ideas, as int might not be large enough to store the address etc. </p>
  
  <p>So whats the best practice to get a unique identifier from the object, which will be a portable solution ? </p>