title: casting short*/double* to int* and back and dereference
body: <p>as I am quite new to C++ and still have to learn a lot, please bear with me and maybe some stupid questions:</p>
  
  <p>Basically, I am declaring a <code>map&lt;wstring, int*&gt;</code>, as most of the variables I am going to dereference and use are <code>int</code>s (4 bytes). Unfortunately, there are rare ones being <code>double</code>s (8 bytes) or <code>short</code>s (2 bytes) and I don't have any influence on this. For the sake of simplicity and as I want to learn something I'd like to read all of the pointers into the same map. Here are my thoughts:</p>
  
  <pre><code>map[wstring] = (int*) short*;//or double*
  </code></pre>
  
  <p>Would the above work in terms of that only the beginning of the short's or double's memory address is stored in the map and not the memory's actual content?</p>
  
  <p>As I know, which keys are different I would cast the pointers back to their type before dereferencing:</p>
  
  <pre><code>short = *((short*) map[wstring]); // or double = *((double*) map[wstring]);
  </code></pre>
  
  <p>From my point of limited knowledge this may work. I'd say that, although from the stored memory address there would normally be read 4 bytes, as this is what the map was declared for, now, by casting to short* or double*, I am saying that I'd like to read 2 or 8 bytes from the beginning of the stored address. In fact, it did work at least with shorts but I am not sure if this was just coincidence and I need to be sure.</p>
  
  <p>Again, I am sorry if this is total nonsense and thanks in advance for mind enhancing answers.</p>