Here is a simple code snippet:
class A {
        public int[] arr;
}

class B {
        public int[] arr;
}

void main()
{
        int[] arr;

        A a = new A;
        B b = new B;
        a.arr = arr;
        b.arr = arr;


        arr ~= 1;
        arr ~= -2;

        foreach(data; a.arr)
        {
                writeln(data);
        }

        foreach(data; b.arr)
        {
                writeln(data);
        }
}

it prints nothing, I know that a.arr and b.arr are all slices of arr.

But if a and b want to reference the global arr, it means that any changes in arr will be seen by a and b, and vice versa.

How to?

Thanks ahead.

Reply via email to