Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
34 lines (27 loc) · 864 Bytes

File metadata and controls

34 lines (27 loc) · 864 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// 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 空指针nullptr
f(nullptr); //typedef decltype(nullptr) nullptr_t;
// nullptr_t为nullptr的类型
nullptr_t nl; // 使用nullptr_t定义的任何变量都具有nullptr一样的行为
f(nl);
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.