二者相比 nullptr 的优势:
C++
#include <iostream>
#include <cstring>
using namespace std;
void fun(char const *p)
{
cout << "fun(char const *p)" << endl;
}
void fun(int tmp)
{
cout << "fun(int tmp)" << endl;
}
int main()
{
fun(nullptr); // fun(char const *p)
/*
fun(NULL); // error: call of overloaded 'fun(NULL)' is ambiguous
*/
return 0;
}
阅读量:2018
点赞量:0
收藏量:0