使用nullptr取代NULL

原因:NULL其實是 0 也就是int,但是nullptr是被定義用來當作指標。

void fn(int);
void fn(void*);

fn(123);        // call fn(int)
fn(0);          // call fn(int)
fn(NULL);       // call fn(int),有的 compiler 會 error
fn(nullptr);    // call fn(void*)

Reference

results matching ""

    No results matching ""