```d
struct QueueNode
{

    private int data;
    private QueueNode *next = null;

    this(int data)
    {
        this.data = data;
    }
}
```
I also tried to write it like this too:

```d
struct QueueNode
{

    private:
    int data;
    QueueNode *next = null;

    public:
    this(int data)
    {
        this.data = data;
    }
}
```
(I will use readonly ```@property``` as only way to read them)

But ```data``` and ```next``` can be changed and can be read from outside of the structure. What to do to prevent fields from being read and changed from outside the structure?

Reply via email to