473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

why some operators cannot be overloaded

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

Thanks

Jul 26 '05 #1
4 12891
> 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
Jul 26 '05 #2
Ian
Bangalore wrote:
Hi,
Can anybody explain , why some operators(::, ., .*, sizeof,?:) cannot
be
overloaded in C++?

Because it makes no sense to do so.

Ian
Jul 26 '05 #3
Besides the sense can there be any other reasons??

Suresh

Jul 27 '05 #4
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
Jul 27 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Nitin Bhardwaj | last post by:
Thanx in advance for the response... I wanna enquire ( as it is asked many a times in Interviews that i face as an Engg PostGraduate ) about the overloading capability of the C++ Language. ...
3
by: TJ | last post by:
Hi, I've been referring to many codes and books and always see that the stream insertion operators are overloaded as friends. Why is that? Are there any other overloading that need the same type...
44
by: bahadir.balban | last post by:
Hi, What's the best way to implement an overloaded function in C? For instance if you want to have generic print function for various structures, my implementation would be with a case...
7
by: Sacha Faust | last post by:
if you have a ready only properly like string.Length and I do --(string.Length) I get a compiler problem saying that I can't modify the value of the readonly property. From my understanding, the...
5
by: Suman | last post by:
Having had a look at the C++ FAQ, comp.lang.c++ & comp.std.c++ archives and Stroustrup's FAQs (particularly the following: <url:http://www.research.att.com/~bs/bs_faq2.html#overload-dot/>) I am...
4
by: moleskyca1 | last post by:
What operators cannot be virtual and why? I looked at FAQ and found nothing. I think there are operators that cannot be virtual, but I don't know why?
19
by: Jess | last post by:
Hello, After seeing some examples about operator overloading, I'm still a bit confused about the general syntax. The following is what I think, not sure whether it's correct. 1. For a unary...
5
by: puzzlecracker | last post by:
I don't recall whether operators, which are members of the class, are intherited in subclasses? thanks
2
by: velvizhi | last post by:
why the operators like scope resolution operator,conditional operator,size of operator cant be overloaded?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.