nullとnullptrの違いの概要

2672 ワード

#include 
using namespace std;

void test_null(int* p)
{
    cout << "void test_null(int* p)" << endl;
}

void test_null(int i)
{
    cout << "void test_null(int i)" << endl;
}

int main() {

    // NULL    cstdlib      ,  0(     )
    // NULL             (void*)0,             
    //             
    //test_null(NULL);

    //      void test_null(int i)
    test_null(0);
    // 0             

    // C11      nullptr(   ),    0         NULL
    // nullptr              
    test_null(nullptr);

    return 0;
}