C++11 nullptr
C++11에 추가된 keyword, null pointer 의미
기존 NULL을 사용해왔는데 이는 0L을 의미하기 때문에 명확하게 null을 의미하지는 않는다
Get Jayde’s stories in your inbox
Join Medium for free to get updates from this writer.
stdio.h에 정의되어 있는 NULL의 의미
/- Define NULL pointer value *-
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
즉 C++에서 NULL은 0과 정확히 동일하다
nullptr(std::nulptr_t)은 기존 0, NULL에 대해서 정상적으로 동작한다.
기존 NULL을 nullptr로 casting 또한 가능하다
int *p4 = static_cast<std::nullptr_t>(NULL);
int *p5 = static_cast<std::nullptr_t>(0);





