开发者

Any difference between these two in c++?

开发者 https://www.devze.com 2023-01-12 16:20 出处:网络
new char[1] 开发者_高级运维and new char,essentially the same thing,hm?You have to delete char[1] with delete[] according to the standard, so not quite identical.The objects created are the same, the (

new char[1] 开发者_高级运维and new char,essentially the same thing,hm?


You have to delete char[1] with delete[] according to the standard, so not quite identical.


The objects created are the same, the (invisible) bookkeeping used is not.

That means that you can use the chars in the same way, but you must delete them with the matching delete operator (delete versus delete[])


No. char[1] is of type char*, while char is of type char.

0

精彩评论

暂无评论...
验证码 换一张
取 消