Pure virtual functions in C++11

前端 未结 8 2085
太阳男子
太阳男子 2020-12-29 18:46

In C++98, the null pointer was represented by the literal 0 (or in fact any constant expression whose value was zero). In C++11, we prefer nullptr

相关标签:
8条回答
  • 2020-12-29 19:40

    The = 0 syntax wasn't used to initialize a pointer, it was simply to indicate syntactically that the provided virtual was pure.

    Hence the = 0 syntax for declaring pure virtuals is unchanged.

    0 讨论(0)
  • 2020-12-29 19:43

    Because the syntax says 0, not expression or some other non-terminal matching nullptr.

    For all the time only 0 has worked. Even 0L would be ill-formed because it does not match the syntax.

    Edit

    Clang allows = 0x0, = 0b0 and = 00 (31.12.2013). That is incorrect and should be fixed in the compiler, of course.

    0 讨论(0)
提交回复
热议问题