Why can't you take the address of nullptr?

后端 未结 4 1149
野性不改
野性不改 2021-02-05 00:39

In the C++11 standard, I don\'t understand the reason why taking the address of nullptr is disallowed whereas one is allowed to take the address of their own st

4条回答
  •  梦如初夏
    2021-02-05 00:52

    Both true and false are keywords and as literals they have a type ( bool ). nullptr is a pointer literal of type std::nullptr_t, and it's a prvalue (you cannot take the address of it using &), also nullptr is prvalue so you can't take its address,literal constants are not stored in your program.

    It doesn't make sense to have address.

提交回复
热议问题