title: Handle , Void Pointer , Objects in C++
body: <p>So I was reading the article on <a href="https://stackoverflow.com/questions/1303123/what-is-a-handle-in-c">Handle in C</a> and realized that we implement handles as void pointers so &quot;whatever&quot; Object/data type we get we can cast the void pointer to that kind of Object/data and get its value. So I have basically two concerns :</p>
  <p>1.If lets say in following example taken from <a href="https://stackoverflow.com/questions/1303123/what-is-a-handle-in-c">Handle in C</a></p>
  <pre><code> typedef void* HANDLE;   
   int doSomething(HANDLE s, int a, int b) {
           Something* something = reinterpret_cast&lt;Something*&gt;(s);
           return something-&gt;doit(a, b);
       }
         
  </code></pre>
  <p>If we pass the value to the function <code>dosomething(21,2,2)</code>, does that mean the value HANDLE points to is 21, if yes how does any object when we type cast it to that object, will it be able to use it, like in this example, so in otherwords where does pointer to the object Something, <code>something</code>, will store the value 21.</p>
  <p>2.Secondly the link also says &quot;So in your code you just pass HANDLE around as an opaque value&quot; what does it actually mean? Why do we &quot;pass handle around&quot;? If someone can give more convincing example of handles that uses objects that will be great!</p>