Access outer member of struct from inner struct
Andrey
saasecondbox at yandex.ru
Tue Apr 2 18:20:09 UTC 2019
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
> {
> void write(string text)
> {
> read(text.length);
> writeln(q);
> }
> }
> }
>
> void main()
> {
> Outer ttt;
> ttt.run();
> }
During compilation I get:
> onlineapp.d(55): Error: this for read needs to be type Outer
> not type Inner
> onlineapp.d(56): Error: need this for q of type ulong
More information about the Digitalmars-d-learn
mailing list