【c++11关键字】nullptr
2020-10-25 本文已影响0人
小鱼号的代码日记
/*
* c++11关键字
* nullptr
* 小鱼号的代码日志
*/
#include <QCoreApplication>
#include <iostream>
using namespace std;
void nullPointer(int *a)
{
cout << "i am a pointer" << endl;
}
template<typename T,typename U>
void func(T t,U u)
{
t(u);
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
nullPointer(0);
nullPointer(NULL); //(void*)0
nullPointer(nullptr);
func(nullPointer,nullptr);
//func(nullPointer,NULL);///BAD
//func(nullPointer,0); ///BAD
func(nullPointer,(int*)0);
return a.exec();
}