Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 10. Operator Functions: Another ... > Limitations on Operator Overloading

Limitations on Operator Overloading

As you saw in the previous section, the overloaded operators give you a powerful tool to make C++ code more beautiful by treating objects of programmer-defined types similarly to variables of built-in numeric types. There are, however, some limitations that C++ places on the use of overloaded operators. Some of these operations will not limit you much, but some are quite essential. In this section, I will discuss these limitations.

What Operators Cannot Be Overloaded

There are some limitations on operator overloading that are not very important for the practicing programmer, at least not at this stage. You cannot overload operator :: (scope), operator .* (member object selector), operator . (class object selector), and operator ?: (conditional operator or arithmetic if). I'm not sure if anybody has a good idea why one needs to overload the scope operator and the conditional operator. The same is true about member object selector and class object selector operators. (Actually, the member object selector operator has not been used here even in its initial meaning.)


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial