NULL对nullptr(为什么它被替换?) [英] NULL vs nullptr (Why was it replaced?)
本文介绍了NULL对nullptr(为什么它被替换?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
只是一个快速问题。我知道在C ++中0x NULL被替换为nullptr在基于指针的应用程序。
Just a quick question. I know that in C++0x NULL was replaced by nullptr in pointer-based applications. I'm just curious of the exact reason why they made this replacement?
在处理指针时,使用nullptr超过NULL是有益的吗?
What is a scenario where using nullptr over NULL is beneficial when dealing with pointers?
推荐答案
nullptr
始终是指针类型。 0
(又称为C的NULL桥接到C ++)可能导致重载函数解析的不明确性,其中包括:
nullptr
is always a pointer type. 0
(aka. C's NULL bridged over into C++) could cause ambiguity in overloaded function resolution, among other things:
f(int);
f(foo *);
这篇关于NULL对nullptr(为什么它被替换?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文