7,NULL与nullptr对比

 1 #include <iostream>
 2 #include <array>
 3 using namespace std;
 4 
 5 void show(int num)
 6 {
 7     cout << "int" << endl;
 8 }
 9 
10 void show(int *p)
11 {
12     cout << "int *" << endl;
13 }
14 
15 void main()
16 {
17     //NULL C风格的空指针会被误认整数
18     //nullptr C++风格的空指针 严格类型匹配
19 
20     show(NULL);
21     show(nullptr);
22     cin.get();
23 }

 

posted @ 2018-03-11 11:52  喵小喵~  阅读(110)  评论(0编辑  收藏  举报