Stroustrup said C ++ should be an extensible but not mutable language.
The point operator (access to attributes) was considered too close to the core of the language to allow overloading.
See Project and evolution of C ++ , p. 242, section 11.5.2. Intelligent links.
When I decided to allow operator overloading -> , I naturally thought that the operator . may be similarly overloaded.
At that time, I considered the following arguments convincing: if obj is an object of a class, then obj.m matters for every member m this class of the object. We try not to change the language by overriding the built-in operations (although this rule is violated for = because of extreme necessity and for unary & ).
If we allowed an overload . for class X , we would not be able to access elements of X usual ways; we would have to use the pointer and -> , but -> and & could also be overridden. I need an extensible language, not mutable.
These arguments are valid, but not conclusive. In particular, in 1990, Jim Adcock suggested allowing operator overloading . just like the operator -> .
The self in this quote is Bjarne Straustrup. You cannot be more authoritative than that.
If you really want to understand C ++ (as in βwhy is thisβ), you should absolutely read this book.
ddaa Feb 06 '09 at 12:09 2009-02-06 12:09
source share