title: Abstract base member variable in base class
body: <p>I want to specify an interface which requires an abstract class to have a certain type as a member variable.</p>
  
  <p>I'll try to replicate the situation here:</p>
  
  <pre><code>class Blob {
    int data[32];
  };
  class Worker {
    string name;
    abstract void workOn(Blob&amp;) = 0;
  }
  
  class Abstract {
    vector&lt;shared_ptr&lt;W&gt;&gt; workerList;
    Blob allTheStuff;
    abstract void somethingElse() = 0;
    void doAllTheWork() {
      for (w : workerList) {
        w-&gt;workOn(allTheStuff);
      }
    }
  };
  
  class B_Blob : public Blob {
    int moreData[4096];
  };
  
  class BulbasaurTrainingCamp : public Abstract {
    B_Blob allTheStuff;
    void somethingElse() {} // implemented
    // this class will accept Bulbasaurs into workerList
  };
  
  class Bulbasaur : Worker {
    Bulbasaur(): name("Fushigidane") {}
    void workOn(Blob&amp; b) {
      // bulbasaurs cover *all* their workspace with crap
      for (int i=0; i&lt;sizeof(b.data[0])/sizeof(b.data); ++i) {
        b.data[i] = *((int*)&amp;("crap"));
      }
      for (i=0; i&lt;sizeof(b.moreData[0])/sizeof(b.moreData); ++i) {
        b.moreData[i] = *((int*)&amp;("crap"));
      }
  }
  </code></pre>
  
  <p>Here, the abstract bas class has a <code>Blob</code>, but the instance of <code>BulbasaurTrainingCamp</code> has a derived <code>B_Blob</code>. It appears that since I gave it the same name, the compiler accepts it. </p>
  
  <p>Is there a name for this? What I want to know is what the behavior is when I do this. Have I overridden the <code>Blob</code> with the <code>B_Blob</code>?</p>
  
  <p>I am basically not sure about whether there is an inaccessible base <code>Blob</code> instance hanging around inside of <code>BulbasaurTrainingCamp</code>. My expectation is that each <code>Bulbasaur</code> will write 16512 (not 16384) bytes of <code>crap</code> across the two member variables of <code>B_Blob</code>. I am hoping that C++ will actually do what appears to be the sensible thing. It's a case of, "it compiles so I think I should be happy, but I'm still not totally sure it's doing what I think it should be doing".</p>