title: C++ dereference a void pointer , converting int ptr to void ptr
body: <p>These lines of code show below error:</p>
  
  <pre><code>int e = 5, * ePtr = &amp;e;
  void * vPtr = ePtr; 
  cout &lt;&lt; *vPtr; 
  </code></pre>
  
  <p>syntax error : </p>
  
  <blockquote>
    <p>`void*' is not a pointer-to-object type </p>
  </blockquote>
  
  <p>I know:</p>
  
  <ol>
  <li>any pointer type can be stored in void pointer type without explicit cast</li>
  <li>dereferencing attempt to void pointer is a syntax error</li>
  </ol>
  
  <p>but if we can not do point # 2, what is the use of point # 1 except for being     syntactically correct? I want to print 5 (i.e. <code>e</code> here) using <code>vPtr</code>..is that possible?</p>
  
  <p>This works fine:</p>
  
  <pre><code>int e = 5, * ePtr = &amp;e;
  void * vPtr = ePtr; //specific to generic Ok!
  double * dPtr = (double *)vPtr; //to let compiler know stoarge size
  cout &lt;&lt; *dPtr; //indirectly it is vPtr i.e. a void ptr, can be deref only if cast
  </code></pre>