Why are pointers to a reference illegal in C++?

前端 未结 5 1749
悲&欢浪女
悲&欢浪女 2020-12-04 14:50

As the title itself mentions - why are pointer to a reference illegal, while the reverse is legal in C++?

5条回答
  •  Happy的楠姐
    2020-12-04 15:19

    What would be the difference between a pointer to a reference (to the object) and a pointer to the actual object? The reference cannot be changed to refer to another object. Just use a regular pointer to the object in question.

    On the other hand, a reference to a pointer, like any other reference, gives you a modifiable handle to a particular variable. It happens to be a pointer in this case.

提交回复
热议问题