title: Calling base class constructor
body: <p>In the program below, is the line </p>
  
  <pre><code>Derived(double y): Base(), y_(y)
  </code></pre>
  
  <p>correct/allowed?  That is, does it follow ANSI rules? </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class Base
  {
   public:
    Base(): x_(0)
    {
     std::cout &lt;&lt; "Base default constructor called" &lt;&lt; std::endl;
    }
    Base(int x): x_(x)
    {
     std::cout &lt;&lt; "Base constructor called with x = " &lt;&lt; x &lt;&lt; std::endl;
    }
  
    void display() const
    {
     std::cout &lt;&lt; x_ &lt;&lt; std::endl;
    }
  
   protected:
    int x_;      
  };
  
  class Derived: public Base
  {
   public:
    Derived(): Base(1), y_(1.2)
    {
     std::cout &lt;&lt; "Derived default constructor called" &lt;&lt; std::endl;
    }
    Derived(double y): Base(), y_(y)
    {
     std::cout &lt;&lt; "Derived constructor called with y = " &lt;&lt; y &lt;&lt; std::endl;
    }
  
    void display() const
    {
     std::cout &lt;&lt; Base::x_ &lt;&lt; ", " &lt;&lt; y_ &lt;&lt; std::endl;
    }
  
   private:
    double y_;      
  };
  
  int main()
  {
   Base b1;
   b1.display();
   Derived d1;
   d1.display();
   std::cout &lt;&lt; std::endl;
   Base b2(-9);
   b2.display();
   Derived d2(-8.7);
   d2.display();
  
   return 0;
  }
  </code></pre>