本文介绍了关于在nullptr上调用delete的C ++ 17标准怎么说?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++ 03标准语言:

C++03 Standard say's:

[...]在任一选择中,如果delete操作数的值为空指针,则该操作无效.[...]

[...] In either alternative, if the value of the operand of delete is the null pointer the operation has no effect.[...]

char *p = nullptr;
delete p; //no effect

这意味着在c ++中删除空指针是有效的.

It means, it is valid to delete null pointer in c++.

关于在nullptr指针上调用delete的C ++ 17标准怎么说?

What C++17 standard say about calling delete on nullptr pointer?

推荐答案

是的,它是有效的,并且会导致noop. 参考

Yes it is valid, and it results in a noop. reference

这篇关于关于在nullptr上调用delete的C ++ 17标准怎么说?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 06:37
查看更多