title: scala overriding class parameters
body: <p>This topic has been discussed before but not answered satisfactorily (in my opinion).
  Consider the following scala code:</p>
  
  <pre class="lang-scala prettyprint-override"><code>class A(a:Int) { val _a=a }
  class A1(val a:Int) { val _a=a }
  
  class B(a:Int) extends A(a)                    // OK
  class C(val a:Int) extends A(a)                // OK
  
  class B1(a:Int) extends A1(a)                  // OK
  class C1(val a:Int) extends A1(a)              // fails
  class D1(override val a:Int) extends A1(a)     // OK  
  </code></pre>
  
  <p>I believe that declaring the class parameter as val only has an effect on the constructor call:
  the parameter is copied instead of passing a reference. However in each case the class field is allocated as a val. is this correct?</p>
  
  <p>Now what I do not understand is why we need the override keyword in the last line.
  Note that we do not declare the classes as case classes so no automatic allocation of fields is going on.</p>
  
  <p>Finally is there a good reason why one even would want to define a class like A1 with a val
  class parameter?</p>
  
  <p>Thanks in advance for all replies.</p>