title: Mismatch of 'this' address when base class is not polymorphic but derived is
body: <p>There is this code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class Base
  {
  public:
      Base() {
          std::cout &lt;&lt; "Base: " &lt;&lt; this &lt;&lt; std::endl;
      }
      int x;
      int y;
      int z;
  };
  
  class Derived : Base
  {
  public:
      Derived() {
          std::cout &lt;&lt; "Derived: " &lt;&lt; this &lt;&lt; std::endl;
      }
  
      void fun(){}
  };
  
  int main() {
     Derived d;
     return 0;
  }
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>Base: 0xbfdb81d4
  Derived: 0xbfdb81d4
  </code></pre>
  
  <p>However when function 'fun' is changed to virtual in Derived class:</p>
  
  <pre><code>virtual void fun(){} // changed in Derived
  </code></pre>
  
  <p>Then address of 'this' is not the same in both constructors:</p>
  
  <pre><code>Base: 0xbf93d6a4
  Derived: 0xbf93d6a0
  </code></pre>
  
  <p>The other thing is if class Base is polymorphic, for example I added there some other virtual function:</p>
  
  <pre><code>virtual void funOther(){} // added to Base
  </code></pre>
  
  <p>then addresses of both 'this' match again:</p>
  
  <pre><code>Base: 0xbfcceda0
  Derived: 0xbfcceda0
  </code></pre>
  
  <p>The question is - why 'this' address is different in Base and Derived class when Base class is not polymorphic and Derived class is?</p>