Hi,

I have a class with a reference to the parent object and a constructor that has the parent as parameter

class foo {
        this ( foo p /* , other params */ ) {
                parent = p;
        }

        foo parent;
}

Of cause, the parent is almost always the object that creates the new intance. So

auto f = new foo(this);

I'd like to set "this" ( the creator ) as default argument if the constructor :

this ( foo p = this ) {...}

I can't. But however, the function, the argument and the current object in body of the constructor are 3 different things and the compiler can distinguish each one.

Is there a way to pass the reference of the caller to the creator as default argument ?

Reply via email to