What is nullptr?
One of the reasons to use nullptr in c++11 is https://www.zhihu.com/question/55936870.
A simple demo of the comparison between nullptr, 0, and (void*)0.
// nullptr
#include <iostream>
using namespace std;
int main()
{
void * p1 = 0;
int p2 = 0;
// if(p1 == p2)
// cout << "1" << endl;
if(p1 == nullptr)
cout << "(void*)0 == nullptr" << endl;
// if(p2 == nullptr)
// cout << "0 == nullptr" << endl;
return 0;
}
南七技校醋酸君出品,转载注明出处。

浙公网安备 33010602011771号