12.12 CREDITS AND SUGGESTIONS FOR FURTHER READING


12.12 CREDITS AND SUGGESTIONS FOR FURTHER READING

The book by Meyers [51] is a "must read" for anyone seriously interested in operator overloading in C++. Many ideas presented in this chapter were much influenced by what Meyers has to say.

The operator overload definitions we showed for the MyString class create separate string objects in the memory even when the strings are identical in value. See [54, 51] on how to create a more efficient reference-counted string class. With reference counting, all strings of the same value will be represented by a single string object in the memory.

Certain operators should not be overloaded, even when so allowed by the language. See the book by Meyers [51] for why the logical operators ‘&&’ and‘|’ and the comma operator ‘,’ should not be overloaded. To summarize Meyers, C++ language specifies that the logical operators ‘&&’ and ‘|’ carry out a short-circuit evaluation of their operands, which causes the right operand to not be evaluated if the truth value of the logical expression can be ascertained from the left operand. Overloading the logical operators causes their short-circuit semantics to change to function-call semantics, entailing the evaluation of both operands. The comma operator should not be overloaded because the left-to-right evaluation of the operands cannot be guaranteed in the overloaded definition.

For additional reading on smart pointers, the reader is referred to [50] and [51].




Programming With Objects[c] A Comparative Presentation of Object-Oriented Programming With C++ and Java
Programming with Objects: A Comparative Presentation of Object Oriented Programming with C++ and Java
ISBN: 0471268526
EAN: 2147483647
Year: 2005
Pages: 273
Authors: Avinash Kak

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net