Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   why some operators cannot be overloaded (http://www.velocityreviews.com/forums/t447312-why-some-operators-cannot-be-overloaded.html)

Bangalore 07-26-2005 06:45 AM

why some operators cannot be overloaded
 
Hi,
Can anybody explain , why some operators(::, ., .*, sizeof,?:) cannot
be
overloaded in C++?

Thanks


benben 07-26-2005 07:31 AM

Re: why some operators cannot be overloaded
 
> Hi,
> Can anybody explain , why some operators(::, ., .*, sizeof,?:) cannot
> be
> overloaded in C++?
>
> Thanks
>


http://www.research.att.com/~bs/bs_f...l#overload-dot



Ian 07-26-2005 07:56 AM

Re: why some operators cannot be overloaded
 
Bangalore wrote:
> Hi,
> Can anybody explain , why some operators(::, ., .*, sizeof,?:) cannot
> be
> overloaded in C++?
>

Because it makes no sense to do so.

Ian

suresh 07-27-2005 02:10 PM

Re: why some operators cannot be overloaded
 
Besides the sense can there be any other reasons??

Suresh


Fabio Fracassi 07-27-2005 03:31 PM

Re: why some operators cannot be overloaded
 
suresh wrote:
> Ian wrote:
>
> > Because it makes no sense to do so.
> >
> > Ian


well thats not entirely true. There are very good reasons to overload either
operator. and operator.* which is why allowing it is seriously considered
for the next version of C++

see: http://www.open-std.org/JTC1/SC22/WG...2004/n1671.pdf

It is usful to implement smart references or other forwarding handles.


> Besides the sense can there be any other reasons??
>
> Suresh


Well it is certainly a good policy not to allow things which make no sence.

The problem with all operator overloads is that it might lead to confusion,
if the overloaded operators work differently from the "normal" version.
In the case of an overloaded operator. There is for example no obvious way
to call member functions of the class which overloads the operator.

If you are interested in why c++ is as it is, you probably want to read
Design & Evolution of C++ by Bjarne Stroustrup.


HTH

Fabio


All times are GMT. The time now is 06:37 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.