nullptr_t
C++11
C언어에서 사용되지는 않으나,
<cstddef>
라이브러리에 존재하는 자료형이다.#include <cstddef> #include <iostream> void f(int*) { std::cout << "Pointer to integer overload\n"; } void f(double*) { std::cout << "Pointer to double overload\n"; } void f(std::nullptr_t) { std::cout << "null pointer overload\n"; } int main() { int* pi {}; double* pd {}; f(pi); f(pd); f(nullptr); // would be ambiguous without void f(nullptr_t) // f(0); // ambiguous call: all three functions are candidates // f(NULL); // ambiguous if NULL is an integral null pointer constant // (as is the case in most implementations) }
--- 참고
'C++ > Syntax' 카테고리의 다른 글
C++ Stack Size (0) | 2021.03.11 |
---|---|
C++ 문자열 (string) (0) | 2021.03.11 |
C++ 배열 (Array) (0) | 2021.03.11 |
C++ 반복문 (0) | 2021.03.11 |
C++ switch (0) | 2021.03.11 |