I was under the impression that the attribute "override" was mandatory when replacing a virtual function in a base class. However, code that leaves this out has no errors using dmd v2.060.

import std.stdio;

class A {
  this() {
    show();
  }
  void show() {
    writeln("A");
  }
}

class B : A {
  this() {
    super();
  }

  // No override and no compiler errors?
  void show() {
    writeln("B");
  }
}

void main() {
  auto b = new B();
  // This prints "B".
}

Also, is there a way to make class A call it's own version of show()?

 - Vijay

Reply via email to