Why do some c++ compilers let you take the address of a literal?

后端 未结 5 494
北荒
北荒 2021-01-03 08:08

A C++ compiler that I will not name lets you take the address of a literal, int *p = &42;

Clearly 42 is an r-value and most compilers refuse to do so.

W

5条回答
  •  半阙折子戏
    2021-01-03 08:52

    Because 42 is the answer to life, the universe and everything. When asked for its address it is the answer itself.

提交回复
热议问题