Answer the following statements true (T) or false (F)

1. When overloading an operator, you can change the behavior of the operator, making + do things that feel like multiplication, but this is unwise.
2. When overloading an operator, you can create a new operator different from the more usual operators.
3. When overloading an operator, you cannot change the number of arguments an operator takes.
4. Overloaded operator <<, when used as an output, returns an ostream& to allow chains of output statements, and similarly the overloaded operator >> returns an istream&

1. True
This unwise mischief is one of the pitfalls of operator overloading.
2. False
You are restricted to the operators provided. (C++ is large enough now, doing this would make it much too large.)
3. True
The compiler recognizes the operators and expects them have the usual of arguments.
4. True
We do this so that our overloaded operator << mimics the behavior of the overloaded operator << for primitive types. Uniformity of behavior of user and built-in types is a goal of C++ design.

Computer Science & Information Technology

You might also like to view...

Computerized information is so tightly bound within the fabric of our society that its trustworthiness and availability has to be assured in order for our basic social functions to operate properly.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Something the author does NOT give as an example of things that can make us think is:

a. Clever names b. Color choice c. Company-specific names d. Whether a link or button is clickable

Computer Science & Information Technology