Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ True false and multiple choice. 1. You can change the behavior of + for the

ID: 641073 • Letter: C

Question

C++

True false and multiple choice.

1. You can change the behavior of + for the int type using operator overloading.

2. Overloading a binary operator as a member requires two arguments.

3. Overloading a binary operator as a stand-alone function requires two arguments.

4. When overloading an operator, you can change the behavior of the operator, making + do things that feel like multiplication, but this is unwise.

5. When overloading an operator, you can create a new operator different from the usual operators.

6. When overloading an operator, you cannot change the number of arguments an operator takes.

7. Overloaded operator <<, when used as an output, returns an ostream& to allow chains of output statements, and similarly the overloaded operator >> returns an istream&

8. An operator overloading is essentially a function that uses a different syntax for invocation.

9. Overloading an operator cannot change the precedence of that operator with respect to other operators.

10. If I need to build an object for return from a function, I can construct that object directly in the return statement.

11. Consider the class Money, in part: class Money { public: Money( ); Money(int theDollar, int theCents); Money(int theDollars); Money(double amount); // other public members int getCents( ) const; int getDollars( ) const; private: int dollars; int cents;Page 2 // other private members }; Note that * is not overloaded in the class, but operator + is overloaded using an operator function with the following declaration: Money operator+(const Money& amt1, const Money& amt2) The question is, given the declarations, Money baseAmount(100, 60); // $100.60 Money fullAmount; which of the following expressions is not legal? a) baseAmount + 25 b) 25 + baseAmount c) 2 * baseAmount d) baseAmount+baseAmount

12. I want to have a nonmember function to have access to the private members of a class. The class must declare that function a a) friend b) inline c) static d) None of the above, nonmember functions cannot have the access described here.

Explanation / Answer

True True False True True False True False True True (d) (a)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote