C++之‘nullptr’ was not declared in this scope
生活随笔
收集整理的這篇文章主要介紹了
C++之‘nullptr’ was not declared in this scope
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在vim里面寫了一個簡單cpp文件,為了避免野指針,需要指針初始化
char *p2 = nullptr
1、編譯時報錯如下
2、解決辦法
編譯加上
g++ -std=gnu++0x int.cpp -o int
3、C里面的null和C++里面的nullptr、NULL介紹
NULL在C++中的定義
/* Define NULL pointer value */ #ifndef NULL#ifdef __cplusplus#define NULL 0#else /* __cplusplus */#define NULL ((void *)0)#endif /* __cplusplus */ #endif /* NULL */
總結
以上是生活随笔為你收集整理的C++之‘nullptr’ was not declared in this scope的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C++之inline函数使用总结
- 下一篇: C++之operator关键字(重载操作