import std.stdio : writeln;

class Shape
{
    protected string _name;
    abstract void print();
}

class DBObject
{
    protected string _name;
    abstract void print();
    void saveState()
    {
        writeln(_name);
    }
}

class StorableShape : Shape
{
    private class MyDBObject : DBObject
    {
        this(string name)
        {
            _name = name;
        }

        override void print()
        {
            writeln(_name);
        }

        final override void saveState()
        {
            writeln(this.outer._name, "; ", _name);
        }
    }

    private MyDBObject _store;
    alias _store this;

    this(string outName, string inName)
    {
        _name = outName;
        _store = new MyDBObject(inName);
    }
    
    override void print()
    {
        writeln(_name);
    }
}

void main()
{
    auto s = new StorableShape("first", "second");
    s.print();          // StorableShape._name
    s._store.print();   // StorableShape.MyDBObject._name
    s.saveState();      // StorableShape._name and StorableShape.MyDBObject._name
}
