title: Why will this not dynamic_cast?
body: <p>I am trying to learn about some of the C++ features and coded up a little test. However, when I try to compile, I get the following error (below). Why is this happening and what is the correct way to do it? I'm trying to cast a 32 bit pointer to an 8 bit pointer and print out the contents after the conversion.</p>
  
  <blockquote>
    <p>cast3.cpp:22: error: cannot dynamic_cast 'bigptr' (of type 'uint32_t*') to type 'uint8_t*' (target is not pointer or reference to class)</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  void castme(uint8_t small[], int size);
  
  int main(void)
  {
      uint8_t *small;
  
      uint32_t big = 0x01234567;
      uint32_t *bigptr = &amp;big;
  
      small = dynamic_cast&lt;uint8_t *&gt;(bigptr); // Line 22
      castme(small, sizeof(big));
  
      return 0;
  }
  
  void castme(uint8_t small[], int size)
  {
      for (int i = 0; i &lt; size; i++)
      {
          printf("0x%x\n",  small[i]);
      }
  }
  </code></pre>