Re: Access outer member of struct from inner struct

2019-04-02 Thread Q. Schroll via Digitalmars-d-learn
On Tuesday, 2 April 2019 at 18:52:07 UTC, Jacob Carlborg wrote: On 2019-04-02 20:44, Q. Schroll wrote: After removing the calls to writeln, the error I get is: `this` for `read` needs to be type `Outer` not type `Inner` You cannot access stuff in Outer because Inner objects are not outer o

Re: Access outer member of struct from inner struct

2019-04-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2019-04-02 20:44, Q. Schroll wrote: After removing the calls to writeln, the error I get is: `this` for `read` needs to be type `Outer` not type `Inner` You cannot access stuff in Outer because Inner objects are not outer objects and don't implicitly own an Outer object. In your Inner me

Re: Access outer member of struct from inner struct

2019-04-02 Thread Q. Schroll via Digitalmars-d-learn
On Tuesday, 2 April 2019 at 18:20:09 UTC, Andrey wrote: Hello, In this example how can I access the members "read" and "q" of struct Outer from Inner struct? struct Outer { ulong q = 1; Inner inner; void read(ulong value) { q += value; } void run() {

Access outer member of struct from inner struct

2019-04-02 Thread Andrey via Digitalmars-d-learn
Hello, In this example how can I access the members "read" and "q" of struct Outer from Inner struct? struct Outer { ulong q = 1; Inner inner; void read(ulong value) { q += value; } void run() { q.writeln; read(5); } struct Inner