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

Overloading of Operators

In C++, the concept of programmer-defined types (classes) is an extension of the concept of built-in numeric types. You can define variables of programmer-defined types using the same syntax as for simple numeric variables. Similar to built-in types, you can use object instances of programmer-defined types as array elements or as data members of even more-complex types. You can pass objects of programmer-defined types as parameters and return them from functions. You can set pointers and references to programmer-defined values using the same syntax as for built-in values. You can define pointers as constant pointers. You can define pointers and references as pointers and references to constant values using the same syntax as for built-in types.

These similarities are not accidental. One of the important C++ goals was to treat programmer-defined types in the same way as it treats built-in types. This goal has nothing to do with object-oriented programming, improving productivity of development, enhancing efficiency of maintenance, or any other software engineering consideration. This is a purely aesthetic goal. And this is legitimate. Computer programming, as any creative human activity, has an essential aesthetic component. Although programming books rarely discuss this issue, the programs we write should be as elegant as they should be readable, portable, and maintainable.


  

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


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint