NULL
is not a keyword. C++11's nullptr
is. NULL
is a macro. If you don't directly or indirectly include any header which defines it, then in theory you can just use it for anything.
However, in practice, this is quite impossible because:
NULL
is defined by many standard headers, and headers can (and generally do) indirectly include a lot of other standard headers. You will hardly want to write an enum which prevents its clients from using the standard library.
Using ALL_UPPERCASE
for a non-macro identifier is usually considered bad practice anyway (example reference).
You may deal with legacy code which does not use nullptr
but still relies on NULL
.
You could #undef NULL
, but that's generally a horrible hack. You could no longer write any client code which needs both your enum and the NULL
macro, not to mention the fact that it would create endless confusion for everyone maintaining your code.
enum class NULLSTYLE {
NULL,
NOTNULL
};
This is just a case of bad naming. Make it something like this:
enum class NullStyle {
Null,
NotNull
};