Why it is impossible to create an array of references in c++?

后端 未结 4 1546
庸人自扰
庸人自扰 2020-12-25 12:08

C++ Standard 8.3.2/4 says:

There shall be no references to references, no arrays of references, and no pointers to references.

4条回答
  •  醉酒成梦
    2020-12-25 12:34

    Because indexation into an array is actually defined in terms of an implicit conversion to a pointer, then pointer arithmetic. So to support this, you'd have to also support pointers to references, and define what pointer arithmetic means on them.

提交回复
热议问题