Is there a difference in C++11 between the following pointer initialization:
#include <pwd.h>
int main(int argc, char const *argv[])
{
passwd *p1{};
passwd *p2{nullptr};
return 0;
}
If I understand correctly, p1 is zero-initialized, and p2 is direct-initialized from nullptr. Is it the same thing? Is it possible to use initialization, as in the case of p1, because it requires fewer keystrokes?
lang-cpp
passwd *p3 = nullptr;, which is arguably the most clear in function and intent, regardless of how many precious keystrokes, and the extre half-second it takes to tap them, you're saving.p1is zero-initialized" - technically, it is value-initialized, but sincep1is a pointer type then the resulting value is zero-initialized.