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
instead. But this doesn't work for pure virtual functions:
struct X
{
virtual void foo() = nullptr;
};
Why does this not work? Would it not make total sense? Is this simply an oversight? Will it be fixed?
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.