C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

why some operators cannot be overloaded

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Bangalore
Guest





PostPosted: Tue Jul 26, 2005 6:45 am    Post subject: why some operators cannot be overloaded Reply with quote



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

Thanks

Back to top
benben
Guest





PostPosted: Tue Jul 26, 2005 7:31 am    Post subject: Re: why some operators cannot be overloaded Reply with quote



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

Thanks


http://www.research.att.com/~bs/bs_faq2.html#overload-dot



Back to top
Ian
Guest





PostPosted: Tue Jul 26, 2005 7:56 am    Post subject: Re: why some operators cannot be overloaded Reply with quote



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

Because it makes no sense to do so.


Ian

Back to top
suresh
Guest





PostPosted: Wed Jul 27, 2005 2:10 pm    Post subject: Re: why some operators cannot be overloaded Reply with quote

Besides the sense can there be any other reasons??

Suresh

Back to top
Fabio Fracassi
Guest





PostPosted: Wed Jul 27, 2005 3:31 pm    Post subject: Re: why some operators cannot be overloaded Reply with quote

suresh wrote:
Quote:
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/WG21/docs/papers/2004/n1671.pdf

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


Quote:
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

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.