What exactly is nullptr?

前端 未结 14 2365
无人及你
无人及你 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:30

    Well, other languages have reserved words that are instances of types. Python, for instance:

    >>> None = 5
      File "", line 1
    SyntaxError: assignment to None
    >>> type(None)
    
    

    This is actually a fairly close comparison because None is typically used for something that hasn't been intialized, but at the same time comparisons such as None == 0 are false.

    On the other hand, in plain C, NULL == 0 would return true IIRC because NULL is just a macro returning 0, which is always an invalid address (AFAIK).

提交回复
热议问题