为什么这些运营商不能超载? [英] Why these operators cant be overloaded?

查看:77
本文介绍了为什么这些运营商不能超载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




如您所知,C ++中很少有运算符过载。


它们是:


..,。*,::,?:,new,delete,sizeof,typeid,static_casr,

dynamic_cast,const_cast,reinterpret_cast。


每个

运营商都有这种限制的原因。

有谁知道每个限制的确切原因他们?

Hi,

As you know there are few operators in C++ which cant be overloaded.

They are:

.., .*, ::, ?: , new , delete , sizeof , typeid , static_casr ,
dynamic_cast , const_cast , reinterpret_cast .

Theremust be some reason for this restriction for each of the
operators.

Does anyone know the exact reason for such restriction on each of them?

推荐答案

你可以重载运算符new和delete

you can overload operators new and delete

我不认为新可以超载。 operator new可以超载

但不是新运营商。删除相同。按照任何传统书籍

进行确认。

I dont think "new" can be overloaded. "operator new" can be overloaded
but not "new" operator. Same for delete. Follow any traditional book
for confirmation.


am ********* @ gmail.com 写道:
我不认为新可以超载。 operator new可以超载
但不是新的运营商。删除相同。按照任何传统书籍
进行确认。
I dont think "new" can be overloaded. "operator new" can be overloaded
but not "new" operator. Same for delete. Follow any traditional book
for confirmation.



不同之处是?


您可以拥有自己的类本地运营商new和你自己的全球性的。


Ian


And the difference is?

You can have your own class local operator new and your own global one.

Ian


这篇关于为什么这些运营商不能超载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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