title: Overriding a private function, how is it different from protected?
body: <p>In the following program, if GetPart() was made protected instead of private,  would there be a difference to outside (derived) classes or additional member functions within these classes? i.e. is there a compilation error that could be caused by having this as private that wouldn't exist if the function was protected in the base class?</p>
  
  <p>I discovered that it was possible to override private virtual functions recently, which surprised me. Semantically this seems (to me) to be the job of protected, rather than private.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class A {
  public:
      A() {}
      virtual ~A() {}
  
      virtual void runFn() { GetPart(); }
  
  private:
      virtual void GetPart() = 0;
  };
  
  class B : public A {
  public:
      B() {}
      virtual ~B() {}
  
  private:
      virtual void GetPart() override { std::cout &lt;&lt; "GETPART RUN" &lt;&lt; std::endl; }
  };
  
  int main()
  {
      B b;
      b.runFn();
      return 0;
  }
  </code></pre>
  
  <p>See <a href="http://ideone.com/S9681V" rel="noreferrer">http://ideone.com/S9681V</a> to show that the line does get run, as the function gets overriden properly.</p>