title: Instantiate a derived class object, whose base class ctor is private
body: <p>How to instantiate a derived class object, whose base class ctor is private? </p>
  
  <p>Since the derived class ctor implicitly invokes the base class ctor(which is private), the compiler gives error.</p>
  
  <p>Consider this example code below:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class base
  {
     private:
        base()
        {
           cout &lt;&lt; "base: ctor()\n";
        }
  };
  
  class derived: public base
  {
     public:
        derived()
        {
           cout &lt;&lt; "derived: ctor()\n";
        }
  };
  
  int main()
  {
     derived d;
  }
  </code></pre>
  
  <p>This code gives the compilation error:</p>
  
  <blockquote>
    <p>accessing_private_ctor_in_base_class.cpp: In constructor
    <code>derived::derived()': accessing_private_ctor_in_base_class.cpp:9:
    error:</code>base::base()' is private
    accessing_private_ctor_in_base_class.cpp:18: error: within this
    context</p>
  </blockquote>
  
  <p>How can i modify the code to remove the compilation error?</p>