在g ++中使用nullptr需要包含哪些头文件? [英] What header file needs to be included for using nullptr in g++?

查看:8450
本文介绍了在g ++中使用nullptr需要包含哪些头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是g ++ 4.4.1,并且想要使用 nullptr ,但我无法找到需要包含哪个头文件。它似乎也不是关键字,因为我的尝试使用它被拒绝作为

 错误:'nullptr'未被声明在这个范围内$ G $ 4.4 $不支持 


解决方案

code> nullptr



在GCC 4.6中添加了对 nullptr 的支持.0:
http://gcc.gnu.org/gcc-4.6 /changes.html


改进了
即将推出的C ++ 0x ISO C ++标准的实验性支持
包括对nullptr的支持(感谢
给Magnus Fromreide),noexcept,
无限制的工会,基于范围的
循环(感谢Rodrigo Rivas Costa),
隐式删除函数和
隐式移动构造函数。

对于早期版本的GCC,如果您想要实验用 nullptr 你可以尝试这个工作区在这个SO问题中:

可以在GCC中模拟nullptr?


I am using g++ 4.4.1 and want to use nullptr, but I am not being able to find which header file is required to be included. It does not seem to be keyword either, because my attempt to use it is rejected as

error: 'nullptr' was not declared in this scope

解决方案

GCC 4.4.1 does not support nullptr.

Support for nullptr was added in GCC 4.6.0: http://gcc.gnu.org/gcc-4.6/changes.html

Improved experimental support for the upcoming C++0x ISO C++ standard, including support for nullptr (thanks to Magnus Fromreide), noexcept, unrestricted unions, range-based for loops (thanks to Rodrigo Rivas Costa), implicitly deleted functions and implicit move constructors.

For earlier versions of GCC, if you want to experiment with nullptr you can try the workaround in this SO question:

Can nullptr be emulated in GCC?

这篇关于在g ++中使用nullptr需要包含哪些头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆