C++ nullptr_t

2021. 3. 11. 16:52·SW개발/C++
반응형

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)
    }

--- 참고

  • cppreference
반응형
저작자표시 (새창열림)

'SW개발 > C++' 카테고리의 다른 글

C++ Stack Size  (0) 2021.03.11
C++ 문자열 (string)  (0) 2021.03.11
C++ array  (0) 2021.03.11
C++ typeinfo  (0) 2021.03.11
C++ 배열 (Array)  (0) 2021.03.11
'SW개발/C++' 카테고리의 다른 글
  • C++ Stack Size
  • C++ 문자열 (string)
  • C++ array
  • C++ typeinfo
Caniro
Caniro
  • Caniro
    Minimalism
    Caniro
  • 전체
    오늘
    어제
    • 전체보기 (319)
      • SW개발 (268)
        • Java Spring (6)
        • C++ (186)
        • Python (21)
        • Linux (16)
        • 알고리즘 (13)
        • Git (4)
        • Embedded (1)
        • Raspberrypi (9)
        • React (3)
        • Web (2)
        • Windows Device Driver (6)
      • IT(개발아님) (46)
        • Windows (26)
        • MacOS (7)
        • Utility (11)
      • 챗봇 짬통 (0)
      • 일상 (2)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    백기선
    스프링 프레임워크 핵심 기술
    EXCLUDE
    맥북 카카오톡 알림 안뜸
    Workspace
    윈도우 명령어
    SunOS 5.1
    spring
    로지텍 마우스 제스처
    windows
    citrix workspace
    dism
    스프링
    mspaint
    KakaoTalk
    unix
    logi options
    윈도우
    시스템 복구
    java
    SFC
    알림
    Windows 11
    MacOS
    그림판
    Solaris 10
    vscode
    제외
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
Caniro
C++ nullptr_t
상단으로

티스토리툴바