本文介绍了在C ++ 11中,NULL是否定义为nullptr?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++ 11实现是否将 NULL 定义为 nullptr

Will C++11 implementations define NULLas nullptr?

这是新的C ++标准规定的吗?

Would this be prescribed by the new C++ standard?

推荐答案


$ b

From the horse's mouth

1 / < clocale> < cstddef> < cstdio> < cstdlib> < cstring& / code>,< ctime> < cwchar> 是一个实现定义的C ++

1/ The macro NULL, defined in any of <clocale>, <cstddef>, <cstdio>, <cstdlib>, <cstring>, <ctime>, or <cwchar>, is an implementation-defined C++ null pointer constant in this International Standard (18.2).

这是由每个实现提供自己的定义,gcc如果我回忆正确地将它定义为 __ nullptr ,它有特殊的检查(例如验证它不用于算术上下文)。

It is up to each implementation to provide its own definition, gcc if I recall correctly defines it to __nullptr for which it has special checks (verifies that it is not used in arithmetic contexts for example).

所以可以将它定义为 nullptr ,你必须检查你的编译器/标准库文档,看看已经做了什么。

So it is possible to define it as nullptr, you will have to check your compiler/Standard Library documentation to see what has been done.

这篇关于在C ++ 11中,NULL是否定义为nullptr?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 06:36