On Monday, 16 January 2017 at 16:47:09 UTC, Nemanja Boric wrote:
On Monday, 16 January 2017 at 16:31:41 UTC, Brian wrote:
[...]

You're missing a cast, since `this` is a reference to a superclass.

import std.stdio : writeln;

abstract class Base(T)
{
    this()
    {
        _this = cast(T)(this);
        assert(_this);
    }

    void hello()
    {
        _this.world();
    }

    private
    {
        T _this;
    }
}


class Sub : Base!Sub
{
    void world()
    {
        writeln("Hello world");
    }
}

void main()
{
    Sub sub = new Sub;
    sub.hello();
}

Yes, it's possible, thank you!

Reply via email to