It is not clear to me. Which is correct?
HMENU hMenu = 0;HMENU hMenu = nullptr;
?
It is not clear to me. Which is correct?
HMENU hMenu = 0;HMENU hMenu = nullptr;?
Windows API came before nullptr. The reason for the introduction of nullptr is that the compiler sometimes gets confused between the "zero integer" and "null pointer". This is usually a problem in function overload. The programmer might also get confused between "zero integer" and "null pointer". Using nullptr is recommended, otherwise nullptr, NULL, and 0 are the same thing.
To make things more confusing, some Windows's null handles are non-zero values. For example the return value for CreateFile is INVALID_FILE_HANDLE when function fails. In this case you must write if(hfile != INVALID_FILE_HANDLE){success...}
The argument being made, is that if you have a habit of writing if(handle), instead of if(handle != specific_null_handle), you end up writing the wrong code when specific_null_handle is not zero. Otherwise if(handle) is the same code as if(handle != nullptr) as far as the compiler is concerned.
To be consistent with Windows API, you should write NULL, or swap NULL with nullptr.
To be pedantic, you should use neither, but instead HMENU hMenu = NULL;.
nullptr is a C++'ism, only standardized in C++11, while Win32 is a C API predating that.
HMENU is an opaque pointer, like other Win32 handles, so NULL is more appropriate than 0.
That said, using either of NULL, 0 or nullptr in that statement will compile to the same machine code in the end, and work the same.