An overloaded + operator takes a class object and a double as operands. For it to be commutative (i.e., a + b and b + a both work):

a. operator+ must be a member function of the class from which the objects are instantiated.
b. operator+ must be a non-member function.
c. It must be overloaded twice; the operator+ function that takes the object as the left operand must be a member function, and the other operator+ function must be a global function.
d. The + operator cannot be overloaded to be commutative.

c. It must be overloaded twice; the operator+ function that takes the object as the left operand must be a member function, and the other operator+ function must be a global function.

Computer Science & Information Technology

You might also like to view...

(Drawing Patterns with Nested for Loops) Write a program that uses for statements to print the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single statement of the form cout << '*'; (this causes the asterisks to print side by side). [Hint: The last two patterns require that each line begin with an ap- propriate number of blanks. Extra credit: Combine your code from the four separate problems into a single program that prints all four patterns side by side by making clever use of nested for loops.]


What will be an ideal response?

Computer Science & Information Technology

You choose the level of compression in the JPEG format by specifying a quality setting.

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

Computer Science & Information Technology