since ptr2 is a reference to ptr1, when you change ptr1 the change is also reflected in ptr2. What you can't do with ptr2 is assign a new value to it like *ptr2 = 2; is an illegal statement because ptr2 is a const.