//// Created by light on 19-11-2.//#include <iostream>using namespace std;void f(int i) {cout<<"void f(int i)" <<endl;}void f(void *p) {cout<<"void f(void *p)" <<endl;}int main() {f(0);// #ifndef __cplusplus// #define NULL ((void *)0)// #else /* C++ */// #define NULL 0// c语言中将NULL定义为空指针,而在c++中直接定义为0,这是因为C++是强类型的,void *是不能隐式转换成其他指针类型的。if(NULL==0) cout<<"NULL==0"<<endl;// f(NULL); // ambiguous,因为NULL==0所以存在二义性 指针也可以是个int的地址// c++11 空指针nullptrf(nullptr); //typedef decltype(nullptr) nullptr_t;// nullptr_t为nullptr的类型nullptr_t nl; // 使用nullptr_t定义的任何变量都具有nullptr一样的行为f(nl);return 0;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。