Thread overview | |||||
---|---|---|---|---|---|
|
July 06, 2019 struct inside struct: Is there a way to call a function of the outside struct from the inner struct? | ||||
---|---|---|---|---|
| ||||
> struct A
> {
> void c() {}
>
> struct B
> {
> void d()
> {
> c();
> }
> }
> }
When compiling this with rdmd I get the message: "Error: this for c needs to be type A not type B". Is there a way to call c from d?
|
July 06, 2019 Re: struct inside struct: Is there a way to call a function of the outside struct from the inner struct? | ||||
---|---|---|---|---|
| ||||
Posted in reply to berni | Now I found this: https://forum.dlang.org/thread/eobdqkkczquxoepsteue@forum.dlang.org Seems to be intentional, that this doesn't work. In my case I'm able to move d() into the outer struct... |
July 06, 2019 Re: struct inside struct: Is there a way to call a function of the outside struct from the inner struct? | ||||
---|---|---|---|---|
| ||||
Posted in reply to berni | On Saturday, 6 July 2019 at 12:33:00 UTC, berni wrote:
> Now I found this: https://forum.dlang.org/thread/eobdqkkczquxoepsteue@forum.dlang.org
>
> Seems to be intentional, that this doesn't work. In my case I'm able to move d() into the outer struct...
You'll need a pointer to the outer struct, or run it in an function where it then passes a pointer of data that's seen in the scope i believe.
|
Copyright © 1999-2021 by the D Language Foundation