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

前端 未结 5 1754
悲&欢浪女
悲&欢浪女 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条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 15:01

    Because a reference is not a thing that can be pointed at, which in turn is because it does not actually have to be represented anywhere in memory. References exist to give alternate names to already-existing things. You can get a pointer to the renamed thing, but that is a pointer to a value, not a pointer to a reference.

提交回复
热议问题