title: adding virtual function to the end of the class declaration avoids binary incompatibility?
body: <p>Could someone explain to me why adding a virtual function to the end of a class declaration avoids binary incompatibility?</p>
  
  <p>If I have:</p>
  
  <pre><code>class A
  { 
    public:
      virtual ~A();
      virtual void someFuncA() = 0;
      virtual void someFuncB() = 0;
      virtual void other1() = 0;
    private:
      int someVal;
  };
  </code></pre>
  
  <p>And later modify this class declaration to:</p>
  
  <pre><code>class A
  { 
    public:
      virtual ~A();
      virtual void someFuncA() = 0;
      virtual void someFuncB() = 0;
      virtual void someFuncC() = 0;
      virtual void other1() = 0;
    private:
      int someVal;
  };
  </code></pre>
  
  <p>I get a coredump from another .so compiled against the previous declaration.  But if I put someFuncC() at the end of the class declaration (after "int someVal"):</p>
  
  <pre><code>class A
  { 
    public:
      virtual ~A();
      virtual void someFuncA() = 0;
      virtual void someFuncB() = 0;
      virtual void other1() = 0;
    private:
      int someVal;
    public:
      virtual void someFuncC() = 0;
  };
  </code></pre>
  
  <p>I don't see coredump anymore.  Could someone tell me why this is?  And does this trick always work?</p>
  
  <p>PS. compiler is gcc, does this work with other compilers?</p>