We reproduce the class Money here, 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;// other private
members};Note that * is not overloaded in the class, but operator + is
overloaded using an operator function with the following declaration:
Money
const 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 operations are legal? If so, why? If not, why not?
a)```
BaseAmount + 25;
```
B. ```
25 + BaseAmount;
```
C. ```
baseAmount = 2 * baseAmount;
```
D. ```
baseAmount+baseAmount.
Part a) The compiler notes the left hand argument for + is a Money object, and the
right hand object is an int. It looks for an operator overloading with a Money left
hand argument. It finds the overloading with two Money parameters. So it then looks
for a way to convert an int object to a Money object. It finds the Money(int)
constructor, which it uses. Then it has the argument-parameter type match necessary
to invoke the operator+(const Money&,const MoneyADD&) overloaded
operator.
Part b) is quite similar to a)
Part c) is illegal, not because we couldn’t overload operator*, but because we did not
do so.
Part d) is a straightforward call to
```
operator+(baseAmount,baseAmount)
```
You might also like to view...
Which type of loop uses a pretest to initialize a counter variable and then increment the counter variable at the end of each iteration?
a. The Do Until Loop b. The Count Until Loop c. The Do While Loop d. The For…Next Loop
The ________ is a searchable set of macro actions that can retrieve actions based on keywords
A) Submacro B) Action Guide C) Program Flow D) Action Catalog
The mysql_fetch_row() function returns the ____________________ in the current row.
Fill in the blank(s) with the appropriate word(s).
Which of the following would not be considered an operating system resource?
A. RAM B. CPU (central processing unit) C. Storage D. URL (Uniform Resource Locator)