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

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

问题描述

我正在使用 g++ 4.4.1 并想使用 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 不支持 nullptr.

GCC 4.4.1 does not support nullptr.

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

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

改进了对即将推出的 C++0x ISO C++ 标准,包括对 nullptr 的支持(谢谢致 Magnus Fromreide),除了,不受限制的联合,基于范围的循环(感谢 Rodrigo Rivas Costa),隐式删除的函数和隐式移动构造函数.

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.

对于早期版本的 GCC,如果您想尝试使用 nullptr,您可以尝试以下 SO 问题中的解决方法:

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

可以在 GCC 中模拟 nullptr 吗?

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

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