Re: "this" as default parameter for a constructor.

2021-04-13 Thread Mathias LANG via Digitalmars-d-learn
On Sunday, 11 April 2021 at 20:38:10 UTC, Pierre wrote: 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

Re: "this" as default parameter for a constructor.

2021-04-13 Thread Pierre via Digitalmars-d-learn
On Monday, 12 April 2021 at 13:14:27 UTC, Kagamin wrote: class foo { this ( foo p /* , other params */ ) { parent = p; } foo create() { return new foo(this); } void use() { foo f = create(); }

Re: "this" as default parameter for a constructor.

2021-04-12 Thread Jack via Digitalmars-d-learn
On Sunday, 11 April 2021 at 20:38:10 UTC, Pierre wrote: 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

Re: "this" as default parameter for a constructor.

2021-04-12 Thread Kagamin via Digitalmars-d-learn
class foo { this ( foo p /* , other params */ ) { parent = p; } foo create() { return new foo(this); } void use() { foo f = create(); } foo parent; }

"this" as default parameter for a constructor.

2021-04-11 Thread Pierre via Digitalmars-d-learn
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