'this' in base class out contract

Michael Shulman viritrilbia at gmail.com
Sat Jun 4 00:25:03 PDT 2011


Why does the following code fail the assertion?

class A {
  void foo()
    out  { assert(stored is this); }
    body { }
}

A stored;

class B : A {
  void foo() { stored = this; }
}

void main () {
  B x = new B();
  x.foo();
}


More information about the Digitalmars-d-learn mailing list