What exactly is nullptr?

前端 未结 14 2374
无人及你
无人及你 2020-11-22 01:12

We now have C++11 with many new features. An interesting and confusing one (at least for me) is the new nullptr.

Well, no need anymore for the nasty mac

14条回答
  •  盖世英雄少女心
    2020-11-22 01:44

    It is a keyword because the standard will specify it as such. ;-) According to the latest public draft (n2914)

    2.14.7 Pointer literals [lex.nullptr]

    pointer-literal:
    nullptr
    

    The pointer literal is the keyword nullptr. It is an rvalue of type std::nullptr_t.

    It's useful because it does not implicitly convert to an integral value.

提交回复
热议问题