11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 23A New Assignment Operator,Should You Decide to Accept ItIn This Chapter Introduction to the assignment operator Why and when the assignment operator is necessary Similarities between the assignment operator and the copy constructorThe intrinsic data types are those that are built in the language, such asint, float, double, and so on, plus the various pointer types. Chapter 3and Chapter 4 describe the operators that C++ defines for the intrinsic datatypes. C++ enables the programmer to define the operators for classes thatthe programmer has created in addition to these intrinsic operators. This iscalled operator overloading.Normally, operator overloading is optional and not attempted by beginningC++ programmers. A lot of experienced C++ programmers (including me)don’t think operator overloading is such a great idea either. However, youmust figure out how to overload one operator: the assignment operator.Comparing Operators with FunctionsAn operator is nothing more than a built-in function with a peculiar syntax.The following additiona + bcould be understood as though it were writtenoperator+(a, b)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!