Why does this extremely simple operation not work?

d coder dlang.coder at gmail.com
Tue Feb 12 09:07:08 PST 2013


In D, class objects are implicitly pointers. So try the following code.

class Parent {}
class Child : Parent {}

void myFunc(Parent obj) {
  import std.stdio;
  writeln("got ", obj);
}

void main() {
  Child myChild = new Child();
  myFunc(myChild);
}


More information about the Digitalmars-d mailing list