If you want to write an iterator, you usually write 

```
T* operator->() const;

```

My problem is understanding this "const" with pointers and reference.

For instance, you can write the following struct:

```
struct A{
   int* x;

   A(int& x0):x{&x0}{}
   int* ptr() const {return x;}
   int& ref() const {return *x;}
};

```

And you can use it this way:

```
int x = 10;
const A a{x};

int& r = a.ref();
int* p = a.ptr();

*p = 4;
cout << x << endl;   // prints 4

r = 25;
cout << x << endl;  // prints 25

```

But why this compiles and works right (at least with g++ and clang). Why?

As I defined

```
const A a{x};

```

this "a" is const. So when I call 

```
int* p = a.ptr();

```

I am calling ptr() with a const object, so the internal pointer A->x must be "int \* const". But I am returning a "int \*" without const. Why is this correct?

And what happens with the reference? If I call A::ref() with a "const A", what's the type this function returns? Something like "int& const"??? <--- I suppose this is the same as "int&". 

Thanks for your help.