title: Convert array of pointers of derived class to array of base class pointers
body: <p>Consider an inheritance hierarchy like this:
  <code>
       A
     /  \
    B1   B2
     \   /
       C
       |
       D
  </code>
  Realized in C++ like so:</p>
  
  <pre><code>class A {
  public:
      A() {};
      virtual ~A() = 0;
      double a;
  };
  
  A::~A() {};
  
  class B1 : virtual public A {
  public:
      B1() {}
      virtual ~B1() {}
      double b1;
  };
  
  class B2 : virtual public A {
  public:
      B2() {}
      virtual ~B2() {}
      double b2;
  };
  
  class C : public B1, public B2 {
  public:
      C() {}
      virtual ~C() {}
      double c;
  };
  
  class D : public C {
  public:
      D() {}
      virtual ~D() {}
      double d;
  };
  </code></pre>
  
  <p>Now, obviously I can do something like this:</p>
  
  <pre><code>D *d = new D();
  A *a = (A*) d;
  D *d_down = dynamic_cast&lt;D*&gt;(a);
  assert(d_down != NULL); //holds
  </code></pre>
  
  <p>However, I can't seem to figure out how to get same behavior using arrays. Please consider the following code sample to see what I mean by that:</p>
  
  <pre><code>D *d[10];
  for (unsigned int i = 0; i &lt; 10; i++) {
      d[i] = new D();
  }
  
  A **a = (A**) d;
  D *d_down = dynamic_cast&lt;D*&gt;(a[0]);
  assert(d_down != NULL); //fails!
  </code></pre>
  
  <p>So my questions would be:</p>
  
  <ul>
  <li>Why does to above assertion fail?</li>
  <li>How can I achieve the desired behavior?</li>
  <li>I noticed, by chance, that the dynamic_cast above works if I remove the double fields from classes A through D. Why is that?</li>
  </ul>